asp.net - How to make check boxes checked on a Grid view when one checkbox of a row is checked? -
i have gridview. consisits of 2 checkbox item templates.
<asp:gridview id="gridview2" runat="server" autogeneratecolumns="false" cellpadding="4" forecolor="#333333" gridlines="none" <columns> <asp:boundfield datafield="student_name" headertext="student name" sortexpression="student_name" > <itemstyle horizontalalign="center"></itemstyle> </asp:boundfield> <asp:boundfield datafield="student_id" headertext="student id" itemstyle-horizontalalign="center" sortexpression="student_id" readonly="true" > <itemstyle horizontalalign="center"></itemstyle> </asp:boundfield> <asp:templatefield headertext="practical test"> <itemtemplate> <asp:checkbox autopostback="false" checked="true" id="checkboxtheory" runat="server" /> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="theory test"> <itemtemplate> <asp:checkbox autopostback="false" checked="true" id="checkboxpractical" runat="server" /> </itemtemplate> </asp:templatefield> </columns>
when checking 1 of checkbox of row of grid view ,i wants make check other checkbox automatically..and vice versa.. how possible?
on server side need change checkbox has autopostback="true"
, add oncheckedchanged="checkboxtheory_checked"
system can postback when select it.
then can use along lines of:
sub checkboxtheory_checked (sender object, e eventargs) dim checkboxtheory checkbox = sender dim gvrow gridviewrow = directcast(checkboxtheory.namingcontainer, gridviewrow) dim checkboxpractical checkbox = gvrow.findcontrol("checkboxpractical") if checkboxtheory.checked = true checkboxpractical.checked = true else checkboxpractical.checked = false end if end sub
this sender
checkbox, parent container (or namingcontainer
), gridviewrow
, find checkboxpractical
control , check if against other checkbox value.
this long winded way of doing simplest @ explaining method.
Comments
Post a Comment