c# - How to access a checkBox inside a repeater Header? -
i have repeater has checkbox in headertemplate
<asp:repeater id="myrepeater" runat="server"> <headertemplate> <table> <tr> <th> <asp:checkbox id="selectallcheckbox" runat="server" autopostback="true> . . .
i'm wanting know how can value of checkbox in code behind. ideas?
inside itemdatabound method call findcontrol("checkboxid") , cast checkbox
void myrepeater_itemdatabound(object sender, repeateritemeventargs e) { if (e.item.itemtype == listitemtype.header) { checkbox cb = (checkbox)e.item.findcontrol("selectallcheckbox"); bool ischecked = cb.checked; } }
or anytime:
checkbox cb = (checkbox)myrepeater.controls.oftype<repeateritem>().single(ri => ri.itemtype == listitemtype.header).findcontrol("selectallcheckbox");
Comments
Post a Comment