﻿//Select/deselect all GridView checkboxes
//function call:
// aspx: <input type="checkbox" id="chkSelectAll" onclick="SelectCheckboxes(this, '<%=MyGridView.ClientID %>')" />
// c#: string scriptUrl = ResolveUrl("~/Scripts/SelectAllGridViewCheckboxes.js");
//     ClientScript.RegisterClientScriptInclude(this.GetType(), "SelectCheckboxes", scriptUrl);
function SelectCheckboxes(checkBox, gridView)
{
    checked = checkBox.checked;
    checkoxCollection = document.getElementById(gridView).getElementsByTagName("input");
    for(i = 0; i < checkoxCollection.length; i++)
        if(checkoxCollection[i].type == "checkbox")
            checkoxCollection[i].checked = checked;
}
