title: Select All CheckBoxes in GridView ASP.NET using JQuery
body: <p>I have checkBoxes in my Gridview templete columns called "Category A" and "Category B".
  I want Select-All functionality, i.e. when the user checks the Select-All check Box in category A column, all the checkboxes must get checked under that column. Same for Category B. 
  I am trying with the code below. The problem with my code is, it selects all the check boxes in the entire gridview, "Category A" as well as "Category B"s checkboxes. 
  But, I want only checkboxes selected under the same column.</p>
  
  <pre><code> function SelectAllCheckboxesA(chk) {
                  $('#&lt;%=gvSurveys.ClientID %&gt;').find("input:checkbox").each(function() {
                      if (this != chk) {
                          if ($(this).hasClass('CatA') != false) {
                              this.checked = chk.checked;
                          }
                      }
                      else {
                          alert($(this));
                      }
                  });
              }
  
  
  
  
   &lt;asp:GridView ID="gvSurveys" runat="server" AutoGenerateColumns="false" AllowSorting="True" Width="1500px"&gt;
                             &lt;Columns&gt;
                                &lt;asp:TemplateField&gt;
                                   &lt;HeaderTemplate&gt;Category A
      &lt;asp:CheckBox ID="chkSelectAllCatA" runat="server" Visible="false" onclick="javascript:SelectAllCheckboxesA(this);" CssClass="SACatA" /&gt;
      &lt;/HeaderTemplate&gt;
      &lt;ItemTemplate&gt;
      &lt;asp:CheckBox ID="chkCatA" runat="server" Enabled="false" CssClass="CatA"  /&gt;
      &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
      &lt;asp:TemplateField&gt;
      &lt;HeaderTemplate&gt;
      Category B
      &lt;asp:CheckBox ID="chkSelectAllCatB" runat="server" Visible="false" CssClass="CatB" onclick="javascript:SelectAllCheckboxesB(this);" /&gt;
      &lt;/HeaderTemplate&gt;
      &lt;ItemTemplate&gt;
      &lt;asp:CheckBox ID="chkCatB" runat="server" Enabled="false" /&gt;
      &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  </code></pre>