Viewstate for dynamic controls within dynamically loaded usercontr

S

steven scaife

Hi

I have been banging my head for a few days now with this issue.

I have a page that has several update panels everything is working fine
except for 1 thing.

I am creating a sort of wizard that will build a form that I plan to save to
a database
On stage 2 I load a usercontrol an unspecified number of times depending on
how many fields there will be and add it to an accordian pane.

So if I have two fields there will be two accordian panes this all works fine

Inside of the usercontrol there is a drop down list that adds textboxes
and/or dropdown lists to a placeholder.

When I postback the fields in the usercontrol maintain postback and the
dropdown list has the value selected however the dynamically created controls
appear but don't have any values that have been selected or entered into them.

All the controls have the same ids so thats not the problem.

The page on the load loops through and calls loadcontrol sets the id and
adds the control to the accordianpane which is added to the accoridan.

If i have my code in the init event the dropdown value is not preserved

TIA
 
S

steven scaife

Don't worry about this I sorted it.

for anyone else in the same position I did the following

Added a readonly property to the usercontrol so I could determine whether
the usercontrol ispostback was true or false. The ajax I have implemented
always tells me it is a postback.

I then removed the code from the dropdownlist_slectedindexchanged event and
stuck it in page load when a postback was true so the viewstate information
was pulled through.

TA
 

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,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top