hello guys,
I am getting the following error:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
What i am trying to do is to loop through all of the controls on the page
and if they are Checkboxes and then see if the they are
checked then do something ...
private void Button1_Click(object sender, System.EventArgs e)
{
CheckBox chk=null;
foreach (Control ctl in this.Controls)
{
if (ctl is CheckBox)
chk = (CheckBox) ctl;
if (chk.Checked)
{
Response.Write(chk.Text);
}
}
}
i don't know what is wrong here???