This code for how to Make all Child Check Boxes checked on Master Check Box Checked Event. Checkboxes allow the user to select one or more options from a set. Typically, you should present each checkbox option in a vertical list. Now write the following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title></title> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div style="height:70%;width:70%"> 
<asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="False"  
DataKeyNames="ID" DataSourceID="SqlDataSource1" BackColor="White"  
BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3"  
GridLines="Horizontal" Width="100%"> 
<AlternatingRowStyle BackColor="#F7F7F7" /> 
<Columns> 
<asp:TemplateField> 
<HeaderTemplate> 
    <asp:CheckBox ID="CheckBox2" onclick="headercheckbox(this);" runat="server" /> 
</HeaderTemplate> 
<ItemTemplate> 
    <asp:CheckBox ID="CheckBox1" onclick="childcheckboxes(this);" runat="server" /> 
</ItemTemplate> 
</asp:TemplateField> 
<asp:TemplateField> 
<HeaderTemplate> 
    <asp:LinkButton ID="LinkButton1" runat="server">Delete</asp:LinkButton> 
</HeaderTemplate> 
<ItemTemplate> 
    <asp:LinkButton ID="LinkButton2" runat="server">Delete</asp:LinkButton> 
</ItemTemplate> 
</asp:TemplateField> 
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"  
ReadOnly="True" SortExpression="ID" /> 
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> 
<asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class" /> 
<asp:BoundField DataField="Lastname" HeaderText="Lastname"  
SortExpression="Lastname" /> 
</Columns> 


<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> 
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> 
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> 
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> 
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> 
<SortedAscendingCellStyle BackColor="#F4F4FD" /> 
<SortedAscendingHeaderStyle BackColor="#5A4C9D" /> 
<SortedDescendingCellStyle BackColor="#D8D8F0" /> 
<SortedDescendingHeaderStyle BackColor="#3E3277" /> 


</asp:GridView> 
<asp:SqlDataSource ID="SqlDataSource1" runat="server"  
ConnectionString="<%$ ConnectionStrings:akConnectionString %>"  
SelectCommand="SELECT [ID], [Name], [Class], [Lastname] FROM [nametb]"> 
</asp:SqlDataSource> 

<script type="text/javascript" language="javascript"> 
var gridview = document.getElementById("gridview1"); 
function headercheckbox(checkbox) { 
for (var i = 1; i < gridview.rows.length; i++)  

  gridview.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked = checkbox.checked; 


function childcheckboxes(checkbox) { 
  var atleastekcheck = false; 
  for (var i = 1; i < gridview.rows.length; i++)  
  { 
      if (gridview.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked == false)  
      { 
          atleastekcheck = true; 
          break; 
      } 
      
  } 
   gridview.rows[0].cells[0].getElementsByTagName("INPUT")[0].checked = !atleastekcheck  ; 


</script> 

HostForLIFE.eu ASP.NET Core 1.0 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.