By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,002 Members | 2,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,002 IT Pros & Developers. It's quick & easy.

Viewstate and user control

P: n/a
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!

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


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

"Hardy Wang" <ha*******@hotmail.com> wrote in
news:u7**************@tk2msftngp13.phx.gbl:
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!


Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.