I have a grid view with some check boxes. So after the grid view get updated, I am trying to see whether one particular check box is checked or not. However, I am getting an error says
Null Reference Exception was unhanded by user code
My code:
<asp:TemplateField HeaderText="FollowUp" SortExpression="FollowUp">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
Checked='<%# Bind("FollowUp") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkFollowup" runat="server"
Checked='<%# Bind("FollowUp") %>' Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
Code-behind file:
protected void GViewSrvcCheck_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
foreach (GridViewRow gRow in GViewSrvcCheck.Rows)
{
CheckBox fllwup = gRow.FindControl("chkFollowup") as CheckBox;
if (fllwup.Checked)//this is the one causes the error
{
}
}
}
What goes wrong here? and how can I over come this problem?