dynamic controls: viewstate & web control tree

R

R Reyes

Error:
Failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during the
previous request. For example, when adding controls dynamically, the
controls added during a post-back must match the type and position of the
controls added during the initial request.

Question:
Let's say I have 1 page with a DataList for editing...it contains 2 labels
that are set to values from the database, firstname and lastname. When a
button is clicked we go into editmode, where we see 2 textboxes instead of
labels. The user fills out the values and then presses enter. The error
above pops up.

Does this error mean that I have to create the 2 labels and 2 textboxes on
the first page with Visible=False values for the textboxes to avoid this
error? Since the error says the control tree must match, I'm guessing that
the controls have to be exactly alike on both pages while we control their
viewability with the visible=false/true property.

Is this how it must be done? Let me know plz, thanks.
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top