I have a webpart with SpGridView.
<SharePoint:SPGridView ID="grid" AllowSorting="true" AllowFiltering="true" CssClass="ms-listviewtable"
runat="server" AutoGenerateColumns="false" AllowPaging="True" HeaderStyle-Width="20px" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="select" runat="server" />
</ItemTemplate>
<HeaderTemplate>
<asp:CheckBox ID="selectionCheckBoxHeader" runat="server" OnClick="checkAllCheckBoxes(this)" />
</HeaderTemplate>
</asp:TemplateField>
</Columns>
I add checkbox to header for select all rows of SpGridView.
I use javascrpt for select all.
function checkAllCheckBoxes(invoker) {
var gridView = document.getElementById('<%# grid.ClientID %>');
for (var i = 1; i < gridView.rows.length; i++) {
var rowElement = gridView.rows[i].cells[0];
for (var j = 0; j < rowElement.childNodes.length; j++) {
if (rowElement.childNodes[j].type == "checkbox") {
rowElement.childNodes[j].checked = invoker.checked;
}
}
}
}
Problem is :
getElementById don't find SpGrid !!!