In this code snippets we will discuss about to select all the checkboxes in the gridview by selecting the header checkbox. The functions we covered here is
1. Highlighting selected row
2. Check/Uncheck all records using single checkbox.
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.