for selecting all the check boxes in gridview you can use javascript like this
<pre lang="cs">
function SelectAllCheckboxes(spanChk)
{
var oItem = spanChk.children;
var theBox= (spanChk.type=="checkbox") ?
spanChk : spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i<elm.length;i++)
if(elm[i].type=="checkbox" &&
elm[i].id!=theBox.id)
{
if(elm[i].checked!=xState)
elm[i].click();
}
}
</pre>
this is the gridview with checkbox column ::-
<asp:GridView ID="gvCity" runat="server" AutoGenerateColumns="False" Width="99%"
OnRowCommand="gvCity_RowCommand" OnRowEditing="gvCity_RowEditing" OnRowDeleting="gvCity_RowDeleting"
AllowPaging="True" OnPageIndexChanging="gvCity_PageIndexChanging" CssClass="allgrids"
HeaderStyle-BackColor="#ededec">
<PagerSettings FirstPageText="First" NextPageText="Next" PreviousPageText="Previous"
LastPageText="Last" />
<PagerStyle HorizontalAlign="Right" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);" runat="server"
type="checkbox" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="lblcity" runat="server" Text='<%#Eval("CITY_NAME") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="State">
<ItemTemplate>
<asp:Label ID="lblState" runat="server" Text="Andhra Pradesh" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Country">
<ItemTemplate>
<asp:Label ID="lblCountry" runat="server" Text="India" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Of Creation">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%#Eval("Date") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Actions">
<ItemTemplate>
<asp:LinkButton ID="lbtnEdit" runat="server" Text="Edit" ForeColor="Blue" CommandName="Edit"
CommandArgument='<%#Eval("CITY_ID") %>' />
<asp:LinkButton ID="lbtnDelete" runat="server" Text="Delete" ForeColor="Blue" CommandName="Delete"
CommandArgument='<%#Eval("CITY_ID") %>' OnClientClick="return confirm('Are you sure you want to delete ?');" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>