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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -