Call the below function in the onclick event of the header check box.
function SelectDeselect(headerCheckBox) {
//Get grid view object using grid view id.
var gridViewControl = document.getElementById('<%=GridView1.ClientID %>');
//Get all input tags from the grid view(i.e table).
var inputTagsFromGrid = gridViewControl.getElementsByTagName("input");
//Loop through each input tag and check the type and select or deselect the input field.
for (index = 0; index < inputTagsFromGrid.length; index++) {
//Checking the type as check box or not.
if (inputTagsFromGrid[index].type == 'checkbox') {
//This will be selected or deselected based on the header checkbox selection.
inputTagsFromGrid[index].checked = headerCheckBox.checked;
}
}
}
No comments:
Post a Comment