How to select all checkboxes in just one particular column in GridView?
<p>I have a GridView in which there are two columns of checkboxes i want to add two seperate "check all" text boxes at the top, "check all" above column A should check all the checkboxes in that column only. "check all" above column B should check all the columns in column B only.  Also i am not able to apply groupvalidation. For every row only one of the two columns should get selected. I tried finding solution but when i click on check all at the top it checks all the checkboxes present in the gridview and also there is no group validation. Here is my Code..</p>

<p>HEAD:</p>

<pre><code>&lt;script type = "text/javascript"&gt;
    function Check_Click(objRef) {
        //Get the Row based on checkbox
        var row = objRef.parentNode.parentNode;
        if (objRef.checked) {
            //If checked change color to Aqua
            row.style.backgroundColor = "aqua";
        }
        else {
            //If not checked change back to original color
            if (row.rowIndex % 2 == 0) {
                //Alternating Row Color
                row.style.backgroundColor = "#C2D69B";
            }
            else {
                row.style.backgroundColor = "white";
            }
        }

        //Get the reference of GridView
        var GridView = row.parentNode;

        //Get all input elements in Gridview
        var inputList = GridView.getElementsByTagName("input");

        for (var i = 0; i &lt; inputList.length; i++) {
            //The First element is the Header Checkbox
            var headerCheckBox = inputList[0];

            //Based on all or none checkboxes
            //are checked check/uncheck Header Checkbox
            var checked = true;
            if (inputList[i].type == "checkbox" &amp;&amp; inputList[i] != headerCheckBox) {
                if (!inputList[i].checked) {
                    checked = false;
                    break;
                }
            }
        }
        headerCheckBox.checked = checked;

    }
&lt;/script&gt;
&lt;script type = "text/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++) {
            //Get the Cell To find out ColumnIndex
            var row = inputList[i].parentNode.parentNode;
            if (inputList[i].type == "checkbox" &amp;&amp; objRef != inputList[i]) {
                if (objRef.checked) {
                    //If the header checkbox is checked
                    //check all checkboxes
                    //and highlight all rows
                    row.style.backgroundColor = "aqua";
                    inputList[i].checked = true;
                }
                else {
                    //If the header checkbox is checked
                    //uncheck all checkboxes
                    //and change rowcolor back to original 
                    if (row.rowIndex % 2 == 0) {
                        //Alternating Row Color
                        row.style.backgroundColor = "#C2D69B";
                    }
                    else {
                        row.style.backgroundColor = "white";
                    }
                    inputList[i].checked = false;
                }
            }
        }
    }
&lt;/script&gt;
</code></pre>

<p>BODY:</p>

<pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"&gt;
                        &lt;Columns&gt;
                            &lt;asp:BoundField DataField="RollNo" HeaderText="RollNo" /&gt;
                            &lt;asp:TemplateField HeaderText="Date"&gt;
                                &lt;EditItemTemplate&gt;
                                    &lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
                                    &lt;asp:CalendarExtender ID="CalendarExtender1" runat="server" 
                                        TargetControlID="TextBox1"&gt;
                                    &lt;/asp:CalendarExtender&gt;
                                &lt;/EditItemTemplate&gt;
                                &lt;HeaderTemplate&gt;                                   
                                    &amp;nbsp;
           &lt;/HeaderTemplate&gt;
                                &lt;ItemTemplate&gt;
                                    &lt;asp:TextBox ID="TextBox2" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;asp:CalendarExtender ID="CalendarExtender2"
                                        runat="server" TargetControlID="TextBox2"&gt;
                                    &lt;/asp:CalendarExtender&gt;
                                &lt;/ItemTemplate&gt;
                            &lt;/asp:TemplateField&gt;
                            &lt;asp:BoundField HeaderText="Time" /&gt;
                            &lt;asp:TemplateField HeaderText="Absent"&gt;
                                &lt;ItemTemplate&gt;
                                    &lt;asp:CheckBox ID="CheckBox1" runat="server" Text="Absent" /&gt;
                                    &amp;nbsp;
                                &lt;/ItemTemplate&gt;
                            &lt;/asp:TemplateField&gt;
                            &lt;asp:TemplateField HeaderText="Present"&gt;
                                &lt;HeaderTemplate&gt;
                                    &lt;asp:CheckBox ID="checkAll" runat="server" onclick = "checkAll(this);" /&gt;
                                &lt;/HeaderTemplate&gt;
                                &lt;ItemTemplate&gt;
                                    &lt;asp:CheckBox ID="CheckBox2" runat="server" Text="Present" 
                                        onclick = "Check_Click(this)" /&gt;
                                &lt;/ItemTemplate&gt;
                            &lt;/asp:TemplateField&gt;
                        &lt;/Columns&gt;
                    &lt;/asp:GridView&gt;
</code></pre>
