title: Check Uncheck All Checkboxes in Gridview Using JQuery
body: <p>Check Uncheck All Checkboxes in Gridview Using JQuery</p>
  
  <p>See more: C# ASP.NET jQuery</p>
  
  <p>here not working in all check box on a single click in header check box</p>
  
  <pre><code>     &lt;script type="text/javascript" language="javascript"&gt;
       function CheckAll(Checkbox) {
       var GridView1 = document.getElementById("&lt;%=GridView1.ClientID %&gt;");
       for (i = 1; i &lt; GridView1.rows.length; i++) {
        GridView1.rows[i].cells[3].getElementsByTagName("INPUT")[0].checked       =Checkbox.checked;
         }} 
  </code></pre>
  
  <p></p>
  
  <pre><code>     &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="624px" CssClass="grid" 
          AllowPaging="True" AllowSorting="True" BackColor="White"  OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit"
          BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" PageSize = "5" 
          OnRowUpdating="GridView1_RowUpdating" DataKeyNames="id"&gt;         
              &lt;Columns&gt;
              &lt;asp:TemplateField&gt;
                  &amp;lt;HeaderTemplate&gt;
          &lt;asp:CheckBox ID="chkHeader" runat="server" onclick="CheckAll(this)"/&gt;
              &amp;lt;/HeaderTemplate&gt;
              &lt;ItemTemplate&gt;
              &lt;asp:CheckBox ID="chkchild" runat="server" /&gt;
              &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:BoundField DataField="id" HeaderText="id" SortExpression="id" InsertVisible="False" ReadOnly="True" /&gt;
                  &lt;asp:BoundField DataField="updatedby" HeaderText="updatedby" SortExpression="updatedby" /&gt;
              &lt;asp:BoundField DataField="username" HeaderText="username" SortExpression="username" /&gt;
              &lt;asp:BoundField DataField="password" HeaderText="password" SortExpression="password" /&gt;
              &lt;asp:BoundField DataField="mail" HeaderText="mail" SortExpression="mail" /&gt;
   &lt;asp:BoundField DataField="imagename" HeaderText="imagename" SortExpression="imagename" /&gt;
              &lt;asp:ImageField DataImageUrlField="uploadimage" HeaderText="uploadimage" ControlStyle-Width = "80" ControlStyle-Height = "100"&gt;
              &lt;ControlStyle Height="100px" Width="80px"&gt;&lt;/ControlStyle&gt;
              &lt;/asp:ImageField&gt;
       &lt;asp:CommandField ShowEditButton="True" /&gt;
          &lt;/Columns&gt;  
     &lt;/asp:GridView&gt;
  </code></pre>