title: select all checkbox when header checkbox selected
body: <p>I am trynig to select all checkbox when header checkbox is selected.</p>
  
  <p>I write proper code for that but do'nt know why it's not working.</p>
  
  <p>Can anyone check the issue.</p>
  
  <p>My code--</p>
  
  <pre><code>    &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
          function SelectAllCheckboxes1(chk) {
              $('#&lt;%=GridView1.ClientID%&gt;').find("input:checkbox").each(function () {
                  if (this != chk) { this.checked = chk.checked; }
              });
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:gridview ID="GridView1" runat="server" AutoGenerateColumns="False" 
              DataSourceID="SqlDataSource1"&gt;
              &lt;Columns&gt;
                  &lt;asp:TemplateField&gt;
                      &lt;HeaderTemplate&gt;
                          &lt;asp:CheckBox ID="cbSelectAll" runat="server" onclick="javascript:SelectAllCheckboxes1(this);" AutoPostBack="true"/&gt;    
                      &lt;/HeaderTemplate&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:CheckBox ID="chk" runat="server" /&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /&gt;
              &lt;/Columns&gt;   
          &lt;/asp:gridview&gt;
          &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" 
              ConnectionString="&lt;%$ ConnectionStrings:HRMSConnectionString %&gt;" 
              SelectCommand="SELECT [Name] FROM [Languages]"&gt;&lt;/asp:SqlDataSource&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>