title: Checking a Checkbox (in header template) in Gridview and other Chekcboxes (in item templates) get checked as well jquery
body: <p>I want when I check the checkbox in the header template, then other checkboxes in the Item Template should get checked as well Unfortunately this is not working as expected. I added script referencing a the jquery version 1.6.2 in the head tag of the HTML  then a function that which will be fired after the checked box is clicked. Also on the Checkbox in the Header Template, the onclick function has the jquery function which I wrote in the at the head tag. The Alert is working fine. I did this to help me test that Jquery is working. Notice no AutoPostBack attributes But the Toggling is not working.</p>
  
  <pre><code>//this script is in the head tag
  function toggleSelectionUsingHeaderCheckBox(source) {
      $("#GridView1 input[name$='cbDelete']").each(function () {
          $(this).attr('checked', source.checked);
      });
      //alert('checked');
      //the alert above is working fine
  }
  </code></pre>
  
  <p>the Gridview code from columns</p>
  
  <pre><code>&lt;Columns&gt;
      &lt;asp:TemplateField&gt;
          &lt;HeaderTemplate&gt;
              &lt;asp:CheckBox ID="cbDeleteHeader" runat="server" onclick="toggleSelectionUsingHeaderCheckBox(this);" /&gt;
          &lt;/HeaderTemplate&gt;
          &lt;ItemTemplate&gt;
              &lt;asp:CheckBox ID="cbDelete" runat="server" /&gt;
          &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Id"&gt;
          &lt;ItemTemplate&gt;
              &lt;asp:Label ID="lblEmployeeId" runat="server"
          Text='&lt;%# Bind("EmployeeId") %&gt;'&gt;&lt;/asp:Label&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
      &lt;asp:BoundField DataField="StaffName" HeaderText="Name" /&gt;
      &lt;asp:BoundField DataField="AccessRole" HeaderText="Access Role" /&gt;
      &lt;asp:BoundField DataField="LockStatus" HeaderText="Status" /&gt;
  &lt;/Columns&gt;
  </code></pre>