GridView Select All Client-Side Script
I had used a simple javascript function to check all/uncheck all items in a DataGrid. The same function can be modified to suit the new GridView in ASP.NET 2.0
- Create a template column and as a server-side checkbox to the ItemTemplate
- Create a client-side checkbox in the HeaderTemplate and double-click the item to insert a placeholder for the client-side javascript. The function is as below:
function chkMasterApprove_onclick(aspCheckBoxID,checkVal)
{re = new RegExp(aspCheckBoxID + '$') //to find the generated controlname
for(i = 0; i < document.forms[0].elements.length; i++)
{
elm = document.forms[0].elements[i];
}
if (elm.type == 'checkbox')
{
if (re.test(elm.name))
{
elm.checked = checkVal ;
}
}}
