I have a content VB page where I try to programmatically change Select in SqlDataSource.
My code:
<asp:Content ID="Content6" ContentPlaceHolderID="MainContent" Runat = "server">
<table width="630">
<tr> <td>
Dim Label2 As New Label()
Label2.Text = "Bro"
</td>
<td>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Docs1] WHERE ([Type] = @Type)">
<SelectParameters>
<asp:ControlParameter Name="Type"
ControlID="Label2"
PropertyName="Text"
/>
</SelectParameters>
</asp:SqlDataSource>
</td>
<td>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource2" CellPadding="4" ForeColor="#333333"
GridLines="None" Font-Names="Arial"
>
<AlternatingRowStyle BackColor="White" Font-Size="XX-Small" Font-Bold="False"
ForeColor="#284775" Font-Names="Times New Roman" Font-Underline="False" />
<Columns>
.......
</asp:GridView>
SqlDataSource does not get Label2.Text. What I do not do correctly? I must change select parameter ( from "BLah1" to "Blah2" etc ) several times on the page WITHOUT any action from the user, so no buttons etc and essentially no events, except page_Load. I want to use invisible Label and change their Text and in this way - change select.