Viewstate and user control

H

Hardy Wang

Hi all,
I have a main ASPX page, and a control ASCX page, there is a Repeater
control in ASCX page, and several drop down boxes in main page. These drop
down boxes will trigger postback.
In the ASCX page, if I put code like
private void Page_Load(object sender, System.EventArgs e) {
if (! Page.IsPostBack) {
Data_Binding(); // to populate values in Repeater
}
}
Everytime when the page posts back because of drop down box selection
change, I loose all content in the Repeater. I enabled ViewState in ASCX and
Repeater control. If I let page to run Data_Binding() regardless of postback
status, then it is fine.
In my mind, Viewstate should remember what is for Repeater, I should not
need to commnet out the line if (! Page.IsPostBack) to make page to recreate
the Repeater everytime.

Any idea?

Thanks!
 
C

cbDevelopment

The only time I have seen this behavior is when the main page is loading
the control dynamically using LoadControl().
 

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,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top