Select / unselect all & individual checkbox in gridview

select / unselect all & individual checkbox in gridview

i surfed the net & found may links for the same but along with it i need the same to function for multiple grid
in a page i have a tabcontainer with 6 tabs each having a gridview with checkbox
need a javascript function to select /unselect the gridview check box
and alos when a row is checked few cells from the checked row shld be enabled as all the cell on load are disabled

You can use the following function to get all of the checkboxes that are within a designated parent area.


function getCheckboxes(parent) {
    parent = parent || document;
    var inputs = parent.querySelectorAll('input'),
        i,
        checkboxes = [];
    for (i = 0; i < inputs.length; i += 1) {
        if (inputs[i].type.toLowerCase() === 'checkbox') {
            checkboxes.push(inputs[i]);
        }
    }
    return checkboxes;
}

Hi svibuk,

I assume you want a functionality similar to select all and deselect all.

If it is not complicated for you then you can go through below steps.

(Consider it for one tab, you can implement the same for other tabs as well)

  1. In the first column of your grid you will be having the checkboxes.
  2. Add a class to all the checkboxes appearing in the first column
  3. Through jquery you can change the status of those checkboxes using that class name