R
rn5a
When I do this:
<aspataList ID="dlProducts" runat="server">
<HeaderTemplate>
<table border="0">
<tr>
<td>Category</td>
<td><%# Container.DataItem("Category") %></td>
</tr>
</table>
</HeaderTemplate>
</aspataList>
then ASP.NET generates the
Object variable or With block variable not set.
error pointing to the <%# Container.DataItem("Category") %> line in the
above code but if the offending line is placed within an ItemTemplate
<aspataList ID="dlProducts" runat="server">
<ItemTemplate>
<table border="0">
<tr>
<td>Category</td>
<td><%# Container.DataItem("Category") %></td>
</tr>
</table>
</ItemTemplate>
</aspataList>
then it works fine.
Can't <%# Container.DataItem("Category") %> be used within the
HeaderTemplate in a DataList (Category is a column in a SQL Server 2005
DB table)?
Note that I am binding the data to the DataList control using
SqlDataReader.
<aspataList ID="dlProducts" runat="server">
<HeaderTemplate>
<table border="0">
<tr>
<td>Category</td>
<td><%# Container.DataItem("Category") %></td>
</tr>
</table>
</HeaderTemplate>
</aspataList>
then ASP.NET generates the
Object variable or With block variable not set.
error pointing to the <%# Container.DataItem("Category") %> line in the
above code but if the offending line is placed within an ItemTemplate
<aspataList ID="dlProducts" runat="server">
<ItemTemplate>
<table border="0">
<tr>
<td>Category</td>
<td><%# Container.DataItem("Category") %></td>
</tr>
</table>
</ItemTemplate>
</aspataList>
then it works fine.
Can't <%# Container.DataItem("Category") %> be used within the
HeaderTemplate in a DataList (Category is a column in a SQL Server 2005
DB table)?
Note that I am binding the data to the DataList control using
SqlDataReader.