Nathan Sokalski wrote:
> I have a custom control that I wrote (I inherit from
> System.Web.UI.WebControls.CompositeControl). I dynamically add this
> control to my Page, but I was told that dynamically added controls do
> not survive postback. This seems to be true. However, this seems to
> make dynamically adding controls rather pointless to me, since if you
> cannot retrieve the values of the controls when you perform a
> postback, why add the controls in the firstplace? Can someone help me
> figure out how to retrieve the property values of a dynamically added
> control? Thanks.
They do not survive postback on their own. You have to help them.
You can do that by re-creating them dynamically after the postback.
On top of that, you have to make sure that they get the same ID before and
after the postback.
If not, they will not respond to any events that they were supposed to
handle.
Usually, this means that in the page, you have to keep track of the number
of controls that were added dynamically.
--
Riki