SIGN UP MEMBER LOGIN:    
Blog

Check and Uncheck GridView Check Box

Posted by Hemant Kumar Blogs | C# Language Oct 20, 2011
This Snippet is used to Check and Uncheck the Check boxes of the grid view.Some times we find a requirement to check the Check box which is in the header and to check the each row 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 :-)

share this blog :
post comment