title: Select all CheckBoxes in a particular column in GridView(asp.net)
body: <p>I have a gridview which contains 2 coulmns with checkboxes.
  I have one header column with checkbox named Approve all and another named as Reject all. 
  When I click either of the checkboxes all the child checkboxes present in that gridview get checked but I want only that particular columns checkboxes to be checked. Please help:</p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
      function checkAll(objRef) {
      var GridView = objRef.parentNode.parentNode.parentNode;
      var inputList = GridView.getElementsByTagName("input");
  
      for (var i = 0; i &lt; inputList.length; i++) {
          var row = inputList[i].parentNode.parentNode;
  
              if (inputList[i].type == "checkbox" &amp;&amp; objRef != inputList[i]) {
                  if (objRef.checked) {
                      row.style.backgroundColor = "#c3d9ff";
                      inputList[i].checked = true;
                  }
                  else {
                      if (row.rowIndex % 2 == 0) {
                          row.style.backgroundColor = "#c3d9ff";
                      }
                      else {
                          row.style.backgroundColor = "white";
                      }
  
                      inputList[i].checked = false;
                  }
              }
          }
      }
  &lt;/script&gt;
  
  &lt;asp:GridView ID="gvDetails" runat="server" AlternatingRowStyle-CssClass="myGridAlternatingItemStyle" Width="98%" Height="500px" AllowPaging="false" ShowFooter="false" AutoGenerateColumns="False" &gt;
      &lt;FooterStyle CssClass="myGridTextItem" /&gt;
      &lt;RowStyle CssClass="myGridTextItem"/&gt;
      &lt;SelectedRowStyle CssClass="myGridSelectedItemStyle"/&gt;
      &lt;%-- &lt;HeaderStyle CssClass="myGridHeader" /&gt;--%&gt;
      &lt;AlternatingRowStyle CssClass="myGridAlternatingItemStyle" /&gt;
      &lt;HeaderStyle CssClass="GVFixedHeader" /&gt;
      &lt;Columns&gt;
          &lt;!-- I have few Data columns here --&gt;
          &lt;asp:TemplateField&gt;
              &lt;HeaderTemplate&gt;
                  &lt;asp:CheckBox ID="checkAll" Text="Approve All" TextAlign="Left" runat="server" onclick="checkAll(this);" /&gt;
              &lt;/HeaderTemplate&gt;
              &lt;HeaderStyle CssClass="myGridHeader" ForeColor="White" HorizontalAlign="Center" Width="90px" /&gt;
              &lt;ItemStyle HorizontalAlign="Center" /&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:CheckBox ID="CheckApprove" runat="server" /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField&gt;
              &lt;HeaderTemplate&gt;
                  &lt;asp:CheckBox ID="RejAll" Text="Reject All " TextAlign="Left"  runat="server" onclick="checkAll(this);" /&gt;
              &lt;/HeaderTemplate&gt;
              &lt;HeaderStyle CssClass="myGridHeader" ForeColor="White" HorizontalAlign="Center" Width="80px" /&gt;
              &lt;ItemStyle HorizontalAlign="Center" /&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:CheckBox ID="CheckReject" runat="server" /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;                   
  &lt;/asp:GridView&gt;
  </code></pre>