R
Robert Bevington
Hi everyone,
Can anyone point me in the right direction on this one?
I have a page with a GridView whose column names vary. On Page Load I
search for specific columns (they can be identified by a prefix in the
column name) and then want to create one or more drop-down list boxes
depending on the number of columns. Each drop-down list box is to be
associated to a column. The number and names of the columns is not fixed.
What's the best approach for dealing with this?
I'm trying a For Next Loop at the moment but cannot get the dynamic bits
working. I get three drop-down lists.
<%-- Start Dynamic attribute field creation--%>
<% For attCount = 1 To ATT_Columns.Count
Dim ATT_Name As String = ATT_Columns(attCount)
%>
<asp
ropDownList ID="cboDept" runat="server"
DataSourceID="SqlDataSource1" DataTextField="ATT_Department"
DataValueField="ATT_Department" AppendDataBoundItems="True">
<asp:ListItem>Select from list</asp:ListItem>
</asp
ropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Search4TextConnectionString %>"
SelectCommand="SELECT DISTINCT [ATT_Department] FROM NewTM2 ORDER BY
ATT_Department"></asp:SqlDataSource>
<% Next
%>
How can I replace, for example, ATT_Department with the variable ATT_Name
Any help would be great.
Thanks
Rob
Can anyone point me in the right direction on this one?
I have a page with a GridView whose column names vary. On Page Load I
search for specific columns (they can be identified by a prefix in the
column name) and then want to create one or more drop-down list boxes
depending on the number of columns. Each drop-down list box is to be
associated to a column. The number and names of the columns is not fixed.
What's the best approach for dealing with this?
I'm trying a For Next Loop at the moment but cannot get the dynamic bits
working. I get three drop-down lists.
<%-- Start Dynamic attribute field creation--%>
<% For attCount = 1 To ATT_Columns.Count
Dim ATT_Name As String = ATT_Columns(attCount)
%>
<asp
DataSourceID="SqlDataSource1" DataTextField="ATT_Department"
DataValueField="ATT_Department" AppendDataBoundItems="True">
<asp:ListItem>Select from list</asp:ListItem>
</asp
ConnectionString="<%$ ConnectionStrings:Search4TextConnectionString %>"
SelectCommand="SELECT DISTINCT [ATT_Department] FROM NewTM2 ORDER BY
ATT_Department"></asp:SqlDataSource>
<% Next
%>
How can I replace, for example, ATT_Department with the variable ATT_Name
Any help would be great.
Thanks
Rob