R
rn5a
When I do this:
<asp
ataList ID="dlProducts" runat="server">
<HeaderTemplate>
<table border="0">
<tr>
<td>Category</td>
<td><%# Container.DataItem("Category") %></td>
</tr>
</table>
</HeaderTemplate>
</asp
ataList>
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
<asp
ataList ID="dlProducts" runat="server">
<ItemTemplate>
<table border="0">
<tr>
<td>Category</td>
<td><%# Container.DataItem("Category") %></td>
</tr>
</table>
</ItemTemplate>
</asp
ataList>
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.
<asp

<HeaderTemplate>
<table border="0">
<tr>
<td>Category</td>
<td><%# Container.DataItem("Category") %></td>
</tr>
</table>
</HeaderTemplate>
</asp

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
<asp

<ItemTemplate>
<table border="0">
<tr>
<td>Category</td>
<td><%# Container.DataItem("Category") %></td>
</tr>
</table>
</ItemTemplate>
</asp

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.