function SelectAll(id)
{
var frm = document.getElementById("<%=GvDepartments.ClientID %>");
for (i=0;i<frm.rows.length;i++)
{
cell = frm.rows[i].cells[0];
//loop according to the number of childNodes in the cell
for (j=0; j<cell.childNodes.length; j++)
{
//if childNode type is CheckBox
if (cell.childNodes[j].type =="checkbox")
{
//assign the status of the Select All checkbox to the cell checkbox within the grid
cell.childNodes[j].checked = document.getElementById(id).checked;
}
}
}
}
protected void GvDepartments_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
((CheckBox)e.Row.FindControl("cbSelectAll")).Attributes.Add("onclick", "javascript:SelectAll('" + ((CheckBox)e.Row.FindControl("cbSelectAll")).ClientID + "')");
}
}
Thanks
Pavan Kumar
Mark Answer if this fits the need
.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator