c# - Access parent data in a nested strongly typed repeater -
lets have class structure looks this:
public class { public string poperty1 { get; set; } public string poperty2 { get; set; } public list<b> property3 { get; set; } } public class b { public string property4 { get; set; } public string property5 { get; set; } }
...and couple of nested repeaters this:
<asp:repeater itemtype="a" runat="server"> <itemtemplate> <asp:label text="<%# item.property1 %>" runat="server" /> <asp:repeater runat="server" datasource="<%# item.property3 %>" itemtype="b"> <itemtemplate> <asp:label text="<%# item.property4 %>" runat="server" /> </itemtemplate> </asp:repeater> </itemtemplate> </asp:repeater>
how access property2 second repeater?
well, accessing parent data in nested repeater, in headertemplate, found following solution. it's not prettiest, works:
<%# ((container.parent.parent repeateritem).dataitem a).property2 %>
Comments
Post a Comment