Data not displayed in Repeater

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I created a Repeater (rp1) that is bound to a Datatable, t1. The DataSource
and Datamember properties of rp1 was specified in the properties window as
"ds" and "t1" respectively.

The following code was also included in the HTML view of the form. However,
only the HeaderTemplate rendered in the browser.

<asp:Repeater id="rp1" runat="server">
<HeaderTemplate>
<Table><tr>
<td>Song Name</td>
<td>Artist</td>
<td>Genre</td>
</tr></Table>
</HeaderTemplate>
<ItemTemplate>
<Table><tr>
<td><%# DataBinder.Eval(Container, "DataItem.Song Name") %>
<%# DataBinder.Eval(Container, "DataItem.Artist") %>
<%# DataBinder.Eval(Container, "DataItem.Genre")>
</td>
</tr></Table>
</ItemTemplate>
</asp>
 
2 observations:
1) The markup below is not well-formed. You have there an ending </asp>
instead of </asp:Repeater>,
2) The repeater will render the HeaderTemplate if the datatable is empty
(i.e. no records were retrieved by the query). Use the debugger to step
through the code and verify that you data query retrieved records.
 
There are data within the DataTable and I placed the breakpoint on the 1st
statement at <%# DataBind.Eval(Container, "DatatItem.SongName") %>.

The JScript code was stepped through and the data are still not displayed.
Don't know what's wrong.
 
Back
Top