I'm trying to do a nested repeater as described here but it's erroring out.
My repeater is as follows:
<asp:Repeater ID="HouseholdRepeater" runat="server">
<It开发者_如何学CemTemplate>
<div><b><%# DataBinder.Eval(Container.DataItem,"Name") %></b></div>
<div>
<asp:Repeater ID="ApplicationRepeater" runat="server" DataSource="<%#((DataRowView)Container.DataItem).Row.GetChildrows("Applications") %>"> <!-- error here -->
<ItemTemplate>
<div>
<a href="<%# DataBinder.Eval(Container.DataItem,"Link") %>"><%# DataBinder.Eval(Container.DataItem,"Description") %></a>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
The error message I get is "The server tag is not well formed."
It looks exactly like the example to me. I'm not seeing what is wrong with it. Any ideas how to make this work?
Also, I databind it in the code using an anonymous object from a Linq query.
You are using double quotes to specify your DataSource property, but your DataSource contains double quotes itself. Try enclosing the DataSource in single quotes:
DataSource='<%#((DataRowView)Container.DataItem).Row.GetChildrows("Applications") %>'
Change
Row.GetChildrows("Applications")
to
Row.GetChildrows(""Applications"")
Also change
<a href="<%# DataBinder.Eval(Container.DataItem,"Link")
to
<a href="<%# DataBinder.Eval(Container.DataItem,""Link"")
The DataSource section looks incorrect... the DataSource should be something like this
'<%#DataBinder.Eval(Container, "DataItem.ChildTable") %>'
Change
DataSource="<%#((DataRowView)Container.DataItem).Row.GetChildrows("Applications") %>"
to
DataSource='<%#((DataRowView)Container.DataItem).Row.GetChildrows("Applications") %>'
精彩评论