J
James R. Davis
I have a need to change the select command based on user input (dropdown
lists 1 and 2). I'm using a GridView command that is tied to a
SqlDataSource command as follows:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MTT.mdfConnectionString %>" SelectCommand = "<%#
SQLWhereClause %>" >
</asp:SqlDataSource>
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" runat="server"
CaptionAlign="Top" EnableSortingAndPagingCallbacks="True" Width="100%"
AutoGenerateColumns = "False" DataKeyNames="TipNumber">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="TipNumber"
DataNavigateUrlFormatString="Tip.aspx?Num={0}" DataTextField="TipNumber"
HeaderText="No." />
<asp:BoundField ReadOnly="True" HeaderText="Tip Name" InsertVisible="False"
DataField="TipName" SortExpression="TipName"></asp:BoundField>
<asp:BoundField ReadOnly="True" HeaderText="Teaser" InsertVisible="False"
DataField="TipSuffix" SortExpression="TipSuffix"></asp:BoundField>
</Columns>
</asp:GridView>
What I am attempting to do is create the SelectCommand via a Page_Load sub
as follows:
Protected Sub Page_load()
Dim SQLWhereClause As String = ""
SQLWhereClause = "SELECT * FROM [forum_tips] WHERE "
etc.
I build the String and end the Sub. I have verified that the value of
SQLWhereClause is what I want it to be but the GridView renders nothing as a
result (just as if it didn't have a select command.)
What am I doing wrong, please?1
lists 1 and 2). I'm using a GridView command that is tied to a
SqlDataSource command as follows:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:MTT.mdfConnectionString %>" SelectCommand = "<%#
SQLWhereClause %>" >
</asp:SqlDataSource>
<asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" runat="server"
CaptionAlign="Top" EnableSortingAndPagingCallbacks="True" Width="100%"
AutoGenerateColumns = "False" DataKeyNames="TipNumber">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="TipNumber"
DataNavigateUrlFormatString="Tip.aspx?Num={0}" DataTextField="TipNumber"
HeaderText="No." />
<asp:BoundField ReadOnly="True" HeaderText="Tip Name" InsertVisible="False"
DataField="TipName" SortExpression="TipName"></asp:BoundField>
<asp:BoundField ReadOnly="True" HeaderText="Teaser" InsertVisible="False"
DataField="TipSuffix" SortExpression="TipSuffix"></asp:BoundField>
</Columns>
</asp:GridView>
What I am attempting to do is create the SelectCommand via a Page_Load sub
as follows:
Protected Sub Page_load()
Dim SQLWhereClause As String = ""
SQLWhereClause = "SELECT * FROM [forum_tips] WHERE "
etc.
I build the String and end the Sub. I have verified that the value of
SQLWhereClause is what I want it to be but the GridView renders nothing as a
result (just as if it didn't have a select command.)
What am I doing wrong, please?1