Finding GridView ID
Find the gridview control's id using getElementById method.
var gv = document.getElementById(“GridView1”)
gv variable holds the GridView1 object. Using gv object we can access the grid view control.
Following example demonstrates select all and de-select all checkboxs in the gridview control.
Click on it to open !!!
Description of the above exampleThe above example is used to select all and de-select all check boxes in
called SelBtn which will decide the checkboxs to be select or
de-select. The gvET is the variable which can extracts the properties
and methods of gridview control.
For selecting or de-selecting
check boxes we have to loop it from starting ordinal to the ending
ordinal of the gridview control. Starting ordinal can be 0 at any time.
Ending ordinal is calculated using length of the gridview control. So
length of the gridview control is stored into the rCount.
Find the page count of the gridview. If page cont is greater than 1 then
rowIdx starts with 2 else 1. Here we have to concentrate why we set
rowIdx position. Because the paging informations will be placed in
gridview. So it took one row to show the paging informations.
In for loop we have created row object called rowElement which is used to
access the rows of the gridview. We know already which column holds the
check box. Using check box position we create check box to select or
de-select as demonstrated in the above example. Finally we have changed
the select all and de-select all caption to the button control.
I would love to hear comments about this !!!