Find control doesn’t seem to work with my dynamic check boxes; what i am trying to do is see if a user has checked a check box, eventually which ones as well.
In my code i have a test to see if it is working properly
public void test()
{
// Find control on page.
CheckBox myControl1 = (CheckBox)Table1.FindControl("CBX0");
if (myControl1 != null)
{
// Get control's parent.
Control myControl2 = myControl1.Parent;
Response.Write("Parent of the text box is : " + myControl2.ID);
if (myControl1.Checked == true)
{
Response.Write("check box checked");
}
}
else
{
Response.Write("Control not found");
}
}
when i run my code it does print “parent of the text box is”, however it will not print the parent, which is supposed to be mycontrol2.id
Perhaps the parent control doesn’t have an ID.
Instead try:
to find out the type of the Parent. I think if you’re expecting the parent to be the Table you’re wrong. It will probably be a TableCell.