Creating controls dynamically based on a dynamic control

G

Guest

Hi,

Can someone provide some information on how to create a control dynamically
based on the contents of another dynamic control.

In my experience, all dynamic controls must be created in the Initialize
stage of an ASP.Net page life cycle. Because viewstate is not available in
the initialization stage, I cannot get the value of the 1st dynamic control
to create the second control.

I think building a server control would resolve this issue, but I'm looking
for something a little more straight forward.

Does anyone have any suggestions?
 
G

Guest

Create container control - for example Panel or Literal Control. Then on the
server side add your dynamically created control like this:
pnl.Controls.Add...

Hope that helps!
Regards,
Kostadin Kostov
 
G

Guest

I'm not sure how this will help. Both the panel and literal control are
still populated based on viewstate, which is not available in the Initialize
stage of the page life cycle.

Maybe I wasn't clear with my question. I'm trying to figure out how to
build a dynamic control based on the contents of another dynamic control.

For example, let's say I have a dropdown box that is used to build a
multitude of other controls on the page. This dropdown box is data bound and
as such the information in the box is not available until after the
LoadViewState stage. Unfortunately, I need to add my controls in the Init
stage because my dynamically created controls need to be rebuilt from
viewstate. If I add them in the Load stage, the viewstate information is
lost. Can you see the catch 22 here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top