Hello all,

I want to use code behind variable in mysql command in aspx file here are the codes

[U]code behind[/U]

public vgroup as string
vgroup ="1,7"

[U]in aspx [/U]

 <asp:SqlDataSource ID="SqlCategoryList" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                SelectCommand="SELECT * FROM categorymaster WHERE catgroup in ('<%=vgroup %>')"> 
               
            </asp:SqlDataSource>

Thanks.

You can use "SelectParameters" and then add the value of the parameter in the code behind

<asp:SqlDataSource //Instance Properties
SelectCommand="SELECT * FROM categorymaster WHERE catgroup in (@vgroup)">
   <SelectParameters>
      <asp:Parameter Name="vgroup" />
   </SelectParameters>
</asp:SqlDataSource>

then in the background you can do this
sorry this is c# but vb should be very similar

SqlDataSource1.SelectParameters.Clear();
SqlDataSource1.SelectParameters.Add("vgroup", "1,7");

and then bind your DataSource...
Hope that helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.