I think the short answer is that you cannot, but there must be something to be done to make this happen. I want to make a list of elements, which then have a list of elements inside them, nested only one level. i.e:
Repeater UserControl1 UserControl1 UserControl1 UserControl1 UserControl1 UserControl1 UserControl1
I would really like to avoid using LoadControl, if at all possible, since I am adding to this list inside the server side. Click events, so I cannot execute loadControl on the Init page to get all viewstate properties to work.
I will try to write a quick example psuedo code, it looks like this:
Page.aspx
<asp:repeater runat="Server" id="someRepeater"> <uc:UserControl1 runat="Server" id="ctrlParent" /> </asp:repeater>
UserControl1.ascx
<asp:label id="label1" runat="server" /> <asp:repeater runat="server" id="childRepeater"> <uc:UserControl1 runat="server" id="ctrlChild" /> </asp:repeater>
UserControl1.ascx.vb
If me.HasChildren then 'BindChildRepeater' end if sub Fill(Data as RelevantData) label1.Text = Data.SomeText end sub sub ChildRepeater_ItemDataBound(object as sender, e as someArgs) Dim childCtrl = e.item.findcontrol("ctrlChild") childCtrl.Fill(e.item.dataitem) end sub
source share