470,631 Members | 1,577 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

Re-databinding after user control change event - missing viewstate second time.

I have a user control that is dynamically loaded into a repeater; (so the
user control appears several times)

The user control features a text box and a delete button. When the delete
button is clicked the usercontrol raises an event indicating that the data
in the database that relates to this user control is to be deleted.

In the parent page, when a change in the user control is detected, the
repeater's data binding has to be called again so as to refresh the screen -
and this is where the wheels fall off.

Each user control is effectively dynamically loaded twice; once during
OnInit and then once during the user control's OnChange event handler. On
the second load, the user control's controls do not have the viewstate
reloaded; either because it was previously loaded or because it is happening
too late in the page lifecycle.

In any case, any text that was previously entered into any of the text boxes

If there is another button in the user control that just does a postback
(and does not re-call the Databinding) then the text in the text boxes is
preserved as expected.

A very simple example can be downloaded from
www.tcpiq.com/temp/doubleloading.zip (screen shot at
www.tcpiq.com/temp/doubleloading.jpg). The Delete button as described above
is replaced with the 'Redatabind this repeater' button. Place text any
text box and click 'just post back' and it remains but clicking 'Rebind this
repeater' then it disappears.

Please not that this example is a very simplified example of the real
problem. In the real problem not having the appearance of the controls
preserved between postbacks produces some highly undesirable behaviour.
(think nuclear missiles being launched, etc)

How have people solved this problem?

Is there a Page.ReLoadControlAndReloadAllViewStateSettingPlea se(@"~\MyUserControl1.ascx")
method that I have not found?

Can you force a user control to reset its state from the viewstate?

Thanks in advance

Dave A

Nov 27 '07 #1
0 1690

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Nel | last post: by
4 posts views Thread by Craig Bailey | last post: by
11 posts views Thread by James | last post: by
4 posts views Thread by Alan Walkington | last post: by
1 post views Thread by John Ryan | last post: by
1 post views Thread by joost | last post: by
3 posts views Thread by presspley | last post: by
2 posts views Thread by sky2070 | last post: by
1 post views Thread by Clarice Almeida Hughes | last post: by
2 posts views Thread by Frans Schmidt | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.