Hi,
yes you are if you just add the Control to the Controls collection before
populating (populating happening on initial request).
e.g:
1. Create control instance
2. Add to Controls collection
3. populate inside IsPostBack check
Another solution is to populate before adding to the Controls collection (in
this case populating on every request). This way values are considered to be
initial values and aren't stored to ViewState, but on postback repopulation
happens before postback data processing, so actual selection can be kept.
( Control will save its state only after it is added to the Controls
collection, therefore first to the collection and then populating)
1. Create control instance
2. Populate on every request
3. Add to Controls collection
With some controls like DataGrid etc the latter will mix up with postback
events (databinding loses old state so events cannot be raised). With some
controls this latter one will work, but might be easier to use the first
one.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
Hey, Thanks. I am able to now access the controls. Will I also be able to
get the value of selected item(s) in a dropdown list. Assuming a dropdown
list is one of the dynamically added controls?
Thanks again,
June
Hi,
do you add the controls to the PlaceHolder on postback as well? If you
don't, you need to do that as controls need to be recreated on postback for
them to keep state, be searchable (in other words exist in Controls
collection)
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
I am adding controls(dropdowns and checkboxes) dynamically to a placeholder
or a htmltable control on a web form. I am able to load the page
successfully. However, upon selecting a button(submit) on the page I am
unable to get the values entered in the controls that were added. I can not
even use the findcontrol method to find the controls.
Has anyone done this successfully? It seems to do with state?!?!?!
PLEASE, any ideas would be GREATLY APPRECIATED!!
Thanks,
June
___
Newsgroups brought to you courtesy of
www.dotnetjohn.com
___
Newsgroups brought to you courtesy of
www.dotnetjohn.com