M
Mike P
I am trying to add check all functionality to my grid view, but I can't
get it to work. Here is my gridview :
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox runat="server"
ID="RowLevelCheckBox" />
</ItemTemplate>
</asp:TemplateField>
And here is the code, where Results is the name of my gridview :
protected void CheckAll_Click(object sender, EventArgs e)
{
foreach(GridViewRow gvr in Results.Rows)
//for (int i = 0; i < Results.Rows.Count; i++)
{
CheckBox chkBox =
(CheckBox)Results.FindControl("RowLevelCheckBox");
chkBox.Checked = true;
}
}
But I am getting the error 'object ref not set to instance of object' on
the line chkBox.Checked = true.
Can anybody help me out with this?
Thanks,
Mike
get it to work. Here is my gridview :
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox runat="server"
ID="RowLevelCheckBox" />
</ItemTemplate>
</asp:TemplateField>
And here is the code, where Results is the name of my gridview :
protected void CheckAll_Click(object sender, EventArgs e)
{
foreach(GridViewRow gvr in Results.Rows)
//for (int i = 0; i < Results.Rows.Count; i++)
{
CheckBox chkBox =
(CheckBox)Results.FindControl("RowLevelCheckBox");
chkBox.Checked = true;
}
}
But I am getting the error 'object ref not set to instance of object' on
the line chkBox.Checked = true.
Can anybody help me out with this?
Thanks,
Mike