Functions such as
1. Highlighting selected row
2. Check/Uncheck all records using single checkbox.
3. Highlight row on mouseover event.
Hence once can easily write scripts for GridView, DataGrid and other controls once you know how they are rendered.
To start with I have a GridView control with a header checkbox and checkbox for each individual record
Highlight Row when checkbox is checked
The above function is invoked when you check / uncheck a checkbox in GridView row
First part of the function highlights the row if the checkbox is checked else it changes the row to the original color if the checkbox is unchecked.
The Second part loops through all the checkboxes to find out whether at least one checkbox is unchecked or not.
If at least one checkbox is unchecked it will uncheck the Header checkbox else it will check it
Check all checkboxes functionality
The above function is executed when you click the Header check all checkbox When the Header checkbox is checked it highlights all the rows and checks the checkboxes in all rows.
And when unchecked it restores back the original color of the row and unchecks the checkboxes.
The check all checkboxes checks all the checkboxes only for the current page of the GridView and not all.
Highlight GridView row on mouseover event
Then based on the event type if event is mouseover it highlights the row by changing its color to orange else if the event is mouseout it changes the row’s color back to its original before the event occurred.
The above function is called on the mouseover and mouseout events of the GridView row. These events are attached to the GridView Row on the RowDataBound events refer the code below
You can try out the functionality discussed above using the sample GridView here
1. Internet Explorer 7
2. Mozilla Firefox 3
3. Google Chrome
You can download the source code here.