I have code like this
protected void Button1_Click(object sender, EventArgs e)
{
Table t = new Table() ;
t.ID = "T1";
t.Visible = true;
MyPanel.Controls.Add(t);
}
protected void Button2_Click(object sender, EventArgs e)
{
Table t = (Table)MyPanel.FindControl("T1");
}
I have problem there: Table t = (Table)MyPanel.FindControl("T1");
In variable t, there is now reference to null. I looks like the aplication doesn't know about code-behind generated table. Do I have to "Register" the table somewhere else than only to the MyPanel? Thank you for the answers.
EDIT More information about the problem
I have simple page without masterPage.There is Gridview with a numbers. This numbers mean how many rows and cells the new TAble will have. When the user select a row, I want to create appropriate Table and after click on second button I need collect information from the table. OnInit or PreRender I don't know, how much rows I will need. Does it mean my problem is technically impossible?