Venkat Govind

Venkat Govind

  • 1.2k
  • 568
  • 67.5k

How to check box value dynamically using findcontrol c# asp.

Aug 18 2017 12:48 AM
Hi All,good Morning,
 
below is my html code 
.
<table>
<tr>
<td><asp:CheckBox ID="CheckBox1" runat="server" /></td>
<td><asp:CheckBox ID="CheckBox2" runat="server" /></td>
<td><asp:CheckBox ID="CheckBox3" runat="server" /></td>
<td><asp:CheckBox ID="CheckBox4" runat="server" /></td>
<td><asp:CheckBox ID="CheckBox5" runat="server" /></td>
</tr>
</table>
 
Below code i am trting to get checkbox checked status dynamically but i am getting object refernce not in set Pls provide related code
 
for (int i = 0; i <= 4; i++)
{
CheckBox chk = (CheckBox)this.FindControl("CheckBox"+i);
if (chk.Checked)
{
}
else
{
}
}
 Thanks 
VeKaT G 
 

Answers (5)