In order for you to access the dynamically created user control after a postback, you need to create the control in the Page_Init Event handler. This is so the control will be available for the View State to set its value after the postback. If you create
the control in an event handler after view state has loaded (which is done between the onInit and onLoad events) then the values will not be retained.
pkarthik8
Member
1 Points
7 Posts
How to get values of the dynamically created server controls
Jun 08, 2007 01:56 PM|LINK
i have created a component which will create server controls dynamically from database using Activator.CreateInstance method.
This is rendering all the control in the page perfectly.
Now i need to get the user entered values of the generated controls How to get it ?
Any help would be appreciated.
Karthik.
dynamic controls custom controls adding dynamic controls Dynamic Control Generation
aquillin
Participant
1465 Points
268 Posts
Re: How to get values of the dynamically created server controls
Jun 08, 2007 02:08 PM|LINK
In order for you to access the dynamically created user control after a postback, you need to create the control in the Page_Init Event handler. This is so the control will be available for the View State to set its value after the postback. If you create the control in an event handler after view state has loaded (which is done between the onInit and onLoad events) then the values will not be retained.
-Alan
jackyang
Contributor
5758 Points
773 Posts
Re: How to get values of the dynamically created server controls
Jun 08, 2007 02:10 PM|LINK
Say if it's a textbox, you give it an ID when you created it. Then on the postback, find the control and cast to TextBox and retrieve the value.
See my answer on how to find a control from any given parent control: http://forums.asp.net/t/1118405.aspx
.NET Developer
ASP.NET/jQuery Spell Checker