Sunday, 15 July 2012

c# - Checkbox Select Inside nested repeater -



c# - Checkbox Select Inside nested repeater -

<asp:repeater id="rptdetails" runat="server" onitemdatabound="rptdetails_itemdatabound"> <headertemplate> <table width="100%" cellpadding="0" cellspacing="0" border="0" class="table_box"> </headertemplate> <itemtemplate> <tr> <td style="width: 200px; text-align: left; vertical-align: top" class="pf14"> <asp:label id="lblloginid" runat="server" text='<%#eval("loginid")%>' visible="false"></asp:label> </td> <td align="left" valign="top"> <asp:repeater id="rptsubdetails" runat="server" onitemdatabound="rptsubdetails_itemdatabound"> <headertemplate> <table width="100%" cellpadding="0" cellspacing="0" border="0" style="padding: 5px;" class="separator"> </headertemplate> <itemtemplate> <tr> <td style="width: 300px; text-align: left; background-color: #e4e4e4; padding: 5px;" class="pf14"> <asp:checkbox id="chkmain" runat="server" /> <asp:label id="ltitle" runat="server" text='<%#eval("title")%>'></asp:label> </td> </tr> <tr> <td valign="top"> <asp:repeater id="rptinnerdetails" runat="server" onitemcommand="rptinnerdetails_itemcommand"> <headertemplate> <table width="100%" cellpadding="0" cellspacing="0" border="0" style="padding: 5px;"> </headertemplate> <itemtemplate> <tr> <td align="center" width="50px"> **<asp:checkbox id="chksub" runat="server" />** </td> <td align="left" class="pf14"> <b>comment :</b> <asp:label id="lblcomment" runat="server"><%# eval("comment") %></asp:label> </td> </tr> </itemtemplate> <footertemplate> </table> </footertemplate> </asp:repeater> </td> </tr> </itemtemplate> <footertemplate> </table> </footertemplate> </asp:repeater> </td> </tr> <tr> <td class="separator"></td> </tr> </itemtemplate> <footertemplate> </table> </footertemplate> </asp:repeater>

jquery code not working expected....

<script type="text/javascript"> function toggleselectionusingheadercheckbox() { $("input[name$='chkmain']").each(function () { if ($("input[name$='chkmain']").prop('checked')) { $("input[name$='chksub']").prop('checked', true); } else { $("input[name$='chksub']").prop('checked', false); } }); } </script>

**hello want check uncheck checkbox using jquery have tried when check main check box sub checkbox checked...

i want check kid of main checkbox.**

use : find parent tr , next tr it. , find sub checkboxes within next tr , check or uncheck them.

<script type="text/javascript"> $("input[name$='chkmain']").change(function () { // kid checkbox var $subcheckbox = (this).closest('tr').next('tr').find("input[name$='chksub']"); // check or uncheck kid $subcheckbox.prop('checked', $(this).prop('checked')); }); </script>

c# javascript jquery asp.net

No comments:

Post a Comment