Check and Uncheck GridView Check Box

To use this function common to Asp.Net Programmers who uses this requirement.
Steps to Change in this Function:

  1. Change the GridView ID.
  2. Change the Header Check box ID.
  3. Change the all rows having Check box ID also.

Function CheckUncheckAllCheckBoxAsNeeded()
{

      var
totalCheckboxes = $("#gv1 input[id*='chckAll']:checkbox").size();
      var
checkedCheckboxes = $("#gv1 input[id*='chckAll']:checkbox:checked").size();
      if
(totalCheckboxes == checkedCheckboxes)
      {
            $("#gv1 input[id*='chckbxOneByOne']:checkbox").attr('checked', true);
      }

      else

      {
            $("#gv1 input[id*='chckbxOneByOne']:checkbox").attr('checked', false);
      }

}

Hope this will be helpful to everyone :-)