c# - How to populate a list in a Repeater - HeaderTempalte from the ItemTemplate -
i trying create accessible accordion repeater. need populate list in headertemplate eval in itemtemplate. have runat server it's not shown in codebehind. how can populate ul?
structure:
<asp:repeater runat="server" id="repeater1" onitemdatabound="repeater1_itemdatabound"> <headertemplate> <div class="accordion"> <ul class="tab-titles" role="tablist" runat="server" id="tabtitles"> <li aria-controls="panel1" class="title" id="tab1" role="tab" tabindex="0">tab 1</li> <li aria-controls="panel2" class="title" id="tab2" role="tab" tabindex="0">tab 2</li> </ul> </headertemplate> <footertemplate> </div> </footertemplate> <itemtemplate> <asp:label id="category" runat="server" text='<%# eval("cat") %>' ondatabinding="lblcat_databinding"></asp:label>
code behind:
protected void lblcampus_databinding(object sender, eventargs e) { // tabtitles not found, need populate tab 1 , tab 2, not implemneted yet. }
the header , footer repeaters , other data controls little tricky when exists in event lifecycle. may want want include ul in item template , maybe nest repeater if needed.
alternatively can catch these on itemcreated event well, see this answer on so more details pulling that.
protected void rpter_itemcreated(object sender, repeateritemeventargs e) { if (e.item.itemtype == listitemtype.footer) { e.item.findcontrol(ctrl); } if (e.item.itemtype == listitemtype.header) { e.item.findcontrol(ctrl); } }
Comments
Post a Comment