i have a gridiew control and in the header row i have set a checkbox control and autopostback event is true.and also other one checkbox control on the <itemtemplate>
i want once i check the header row so all checkboxes which is exist in the <itemtemplate> they should also be check in one click .
i am sending my codes please check and find the error when i am wrong
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<columns> <asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="cbdeleteheader" runat="server" AutoPostBack="True" OnCheckedChanged="cbdeleteheader_CheckedChanged" />
</HeaderTemplate>
<itemtemplate>
<asp:CheckBox ID="cbdelete" runat="server" AutoPostBack="True" />
<asp:TemplateField HeaderText="EmployeeID">
<itemtemplate>
<asp:Label ID="lblemployeeID" runat="server" Text='<%# Bind("ID") %>'>
<asp:BoundField DataField="salary" HeaderText="Salary" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="start_date" HeaderText="Start Date" />
<asp:BoundField DataField="City" HeaderText="City" />
protected void cbdeleteheader_CheckedChanged(object sender, EventArgs e)
{
foreach (GridViewRow gridrows in GridView1.Rows)
{
((CheckBox)gridrows.FindControl("cbdelete")).Checked = ((CheckBox)sender).Checked;
}
}
if i check header row so cbdeleteheader check boxes do not get check . please check