I want to access "Checked" property against a checkbox control in GridView, please see my aspx page code below firstly:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="cbDeleteAll" runat="server" OnCheckedChanged="cbDeleteAll_CheckedChanged" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="cbDelete" runat="server" OnCheckedChanged="cbDelete_CheckedChanged" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Employee ID">
<ItemTemplate>
<asp:Label ID="lblEmpId" runat="server" Text='<%# Bind("DeptID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="EmployeeName" HeaderText="Employee Name" />
<asp:BoundField DataField="DeptID" HeaderText="Department" />
</Columns>
</asp:GridView>
Look at the error. It says WebApplication1.CheckBox
. It appears you have a CheckBox class in your app and therefore you're casting to the wrong type. Don't name your classes the same thing as something built into the framework.
To find the offending file put your cursor over CheckBox in your class and press Function 12 or right click it and select Go To Definition. Then right click that class and rename it something more appropriate.
The correct CheckBox class is in System.Web.UI.WebControls namespace.