asp.net - Nested Repeaters in C# -
hi have display hierarchical information (which has 4 levels) within repeater. decided use nested repeater control. found article on msdn, http://support.microsoft.com/kb/306154 shows how use nested repeaters 2 levels of information. can please me extend 4 levels? sample code appriciated. thank you.
html code :
<asp:repeater id="repeater1" runat="server" onitemdatabound="repeater1_itemdatabound"> <itemtemplate> <h1> repeater 1</h1> <asp:repeater id="repeater2" runat="server" onitemdatabound="repeater2_itemdatabound"> <itemtemplate> <h1> repeater 2 </h1> <asp:repeater id="repeater3" runat="server" onitemdatabound="repeater3_itemdatabound"> <itemtemplate> <h1> repeater 3 </h1> <asp:repeater id="repeater4" runat="server" onitemdatabound="repeater4_itemdatabound"> <itemtemplate> <h1> repeater 4 </h1> </itemtemplate> </asp:repeater> </itemtemplate> </asp:repeater> </itemtemplate> </asp:repeater> </itemtemplate> </asp:repeater>
c# code:
using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data; public partial class _default : system.web.ui.page { protected void page_load(object sender, eventargs e) { datatable dt1 = new datatable(); //need assign data in datatable repeater1.datasource = dt1; repeater1.databind(); } protected void repeater1_itemdatabound(object sender, repeateritemeventargs e) { if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem) { repeater repeater2 = (repeater)(e.item.findcontrol("repeater2")); datatable dt2 = new datatable(); //need assign data in datatable repeater2.datasource = dt2; repeater2.databind(); } } protected void repeater2_itemdatabound(object sender, repeateritemeventargs e) { if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem) { repeater repeater3 = (repeater)(e.item.findcontrol("repeater3")); datatable dt3 = new datatable(); //need assign data in datatable repeater3.datasource = dt3; repeater3.databind(); } } protected void repeater3_itemdatabound(object sender, repeateritemeventargs e) { if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem) { repeater repeater4 = (repeater)(e.item.findcontrol("repeater4")); datatable dt4 = new datatable(); //need assign data in datatable repeater4.datasource = dt4; repeater4.databind(); } } }
Comments
Post a Comment