I constructed a Repeater for my XML file roughly like so:
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="samplexml.xml" XPath="level1/level2" />
<asp:Repeater id="category" runat="server" DataSourceID="XmlDataSource1">
<ItemTemplate>
<div class="category">
<h2><%#XPath("@name") %></h2>
<asp:Repeater id="group" runat="server" DataSource='<%# XPathSelect("group") %>'>
<ItemTemplate>
...
</ItemTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
</asp:Repeater>
And now I’m working on how to get the data inside of each on postback. I learned roughly how to get into a RepeaterItem:
foreach (RepeaterItem items in category.Items)
{
Output.Text += items.UniqueID + "<br />";
}
But after a lot of searching MSDN, this site, and others, I haven’t been able to figure out how to get into the group repeater.
Am I missing something obvious here? I’m in .NET 2.0.
You aren’t missing anything obvious. In my experience working with nested Repeaters/ListViews/Etc is a nightmare.
If you have the option to do this using MVC I would recommend that. If not…. Your best bet is probably to get familiar with FindControl. Typically your code will look something like this:
So when a row in the parent repeater binds, you will have to use FindControl to find it’s nested repeater. Good luck!