473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Viewstate and user control

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
1 1414
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
1
by: Simon | last post by:
Hi everyone, I have a quick question that I hope someone can help me with: I've made a user control that contains a text box and some validation functionality. This control has a few extra...
5
by: Steve Richter | last post by:
In my user control I want to read the ViewState dictionary of the Parent control. But this sensible idea is not permitted by the compiler: Compiler Error Message: CS1540: Cannot access...
6
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a...
3
by: Jordan | last post by:
My ASP.NET 1.1. app dynamically loads a user control into a PlaceHolder control that exists in an aspx page. The user control is loaded during the Page_Load event of the aspx. The PlaceHolder's...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
6
by: hitendra15 | last post by:
Hi I have created web user control which has Repeater control and Linkbutton in ItemTemplate of repeater control, following is the code for this control On first load it runs fine but when...
1
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my...
12
by: Nick C | last post by:
Hi How can i reduce the viewstate for my asp.net application. It is getting very large now. What is a good solution? thanks N
0
by: Scott Roberts | last post by:
I always thought that the viewstate "keys" included the control ID. As long as the control IDs were unique, there shouldn't be any conflicts. Well, it appears that that may not be the case with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.