I have a user control that contains a repeater. I use the Eval() method to output data which works for the part of the repeater, but it doesn’t output any data for the (Which uses the same code)
Any ideas why this isn’t working?
I have the following code in the repeater user control:
<asp:Repeater runat="server" ID="repeater1">
<HeaderTemplate>
//Data is not displayed in the HeaderTemplate
<table class="datatable fullwidthpercent">
<tr>
<th>
<%# Eval(Column2Name) %>
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
//Data is displayed in the ItemTemplate
<tr>
<td>
<%# Eval(Column2Name) %>
</td>
</tr>
</ItemTemplate>
The Eval method needs a data item – there is no data item associated with a HeaderTemplate.
From http://www.asp.net/data-access/tutorials/displaying-data-with-the-datalist-and-repeater-controls-vb: