Saturday, March 1, 2014

Check the All the checkboxes in the gridview using JQuery

1. java script code:


<script type="text/javascript" language="javascript">
function SelectAllCheckboxes(chk) {
            $('#<%=GVIndents.ClientID %>').find("input:checkbox").each(function () {
                if (this != chk) {
                    this.checked = chk.checked;
                }
            });
        }
 </script>
2. gridview design code :

 <GridView ID="GVIndents" runat="server" AutoGenerateColumns="False"  >
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox runat="server" Text="Approved" Checked="true" ID="chkAll"
       onclick="SelectAllCheckboxes(this);" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkone" Checked="true" />
 </ItemTemplate>
 </asp:TemplateField>

<;/Columns>

</asp:GridView>

 
   
 

 

No comments:

Post a Comment