B
bienwell
Hi all,
Can we bind the data for a datalist control by an array of column names ?
In my table, I have around 12 field names that contain the value of each
month, year. I have a web page that let users select the number of fields to
perform the query. I already contructed the SQL string and databinding for
the datalist control. The field names selected I stored in the array. In
the datalist control, I cannot specify the column name but use the for loop
to read the field name from the array. The error I've received is the index
of the array is not declared. The syntax like this :
<itemtemplate>
<table width="100%" class="body" border="1" cellpadding="3">
<tr>
<td>
<asp:linkbutton id= "button2" runat= "server" Text= '<%#
DataBinder.Eval(Container.DataItem, "Year") %>' CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "Year") %>' CommandName="select" />
</td>
<% Dim j as integer
For j=0 to UBound(ViewState("ArrField")) %>
<td>
<%# DataBinder.Eval(Container.DataItem,
ViewState("ArrField")(j)) %>
</td>
<% Next %>
</tr>
</table>
</itemtemplate>
I put the link button for the year to perform Annual drilldown data for the
Months of that year.
Do you have any suggestions ? Thanks in advance
Can we bind the data for a datalist control by an array of column names ?
In my table, I have around 12 field names that contain the value of each
month, year. I have a web page that let users select the number of fields to
perform the query. I already contructed the SQL string and databinding for
the datalist control. The field names selected I stored in the array. In
the datalist control, I cannot specify the column name but use the for loop
to read the field name from the array. The error I've received is the index
of the array is not declared. The syntax like this :
<itemtemplate>
<table width="100%" class="body" border="1" cellpadding="3">
<tr>
<td>
<asp:linkbutton id= "button2" runat= "server" Text= '<%#
DataBinder.Eval(Container.DataItem, "Year") %>' CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "Year") %>' CommandName="select" />
</td>
<% Dim j as integer
For j=0 to UBound(ViewState("ArrField")) %>
<td>
<%# DataBinder.Eval(Container.DataItem,
ViewState("ArrField")(j)) %>
</td>
<% Next %>
</tr>
</table>
</itemtemplate>
I put the link button for the year to perform Annual drilldown data for the
Months of that year.
Do you have any suggestions ? Thanks in advance