Hi,
While writing code for creating aspx controls dynamically, I noticed some
strange (at least to me) behavior.
Look at this code;
// FreeQuery : System.Web.UI.Page
// void cmdDo_Click(...)
GridView grid = new GridView();
grid.DataSource = source;
this.Controls.Add(grid); // HERE
The last line fails during execution!
But if I type like so;
//...
form1.Controls.Add(grid);
.... where form1 is generated in FreeQuery.aspx file;
....
<form id="form1" runat="server">
....
no failure will happen.
-------------------------
So what happens?
Why does this.Controls.Add fail?
What's the difference between this and form1?
....
Could you please share your knowledge with us.
Thanks in advance.
--
======
Arman