function SelectAll(b) { var grid = document.getElementById("<%= GridView1.ClientID %>"); // declare variable to contain the grid cell var cell; if (grid.rows.length > 0) { for (i = 1; i < grid.rows.length; i++) { cell = grid.rows[i].cells[0]; if (cell.childNodes[0].type == "checkbox") cell.childNodes[0].checked = b; }}}
protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { lnkSelectAll.Attributes.Add("onclick", "javascript:SelectAll('" + "true" + "')");lnkUnSelectAll.Attributes.Add("onclick", "javascript:SelectAll('" + "false" + "')"); }}