473,387 Members | 1,573 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.

Page_Load and control Persistence

I have a combo that gets bound to an ArrayList in Page_Load. Problem is when
user clicks on a button the page is re-loaded, however the combo's DataSource
is null. How can I get the combo to keep it's reference to the DataSource
during the re-load? I would like for the current selected item in the combo
to survive the page re-load.

private void Page_Load(object sender, System.EventArgs e)
{
if( !IsPostBack )
{
ArrayList aZips = (ArrayList) (Application["Zips"]);
cboZip.DataSource = aZips;
cboZip.DataBind();
}
}
Nov 18 '05 #1
2 1150
You can add the arraylist to viewstate on pageload. and for all consequent
loads you can check for the same in ViewState and load. making objects static
also works fine but not recommended.

Sudhakar Sadasivuni
http://one.mvpblog.com
http://www.mugh.net
"Coffee guy" wrote:
I have a combo that gets bound to an ArrayList in Page_Load. Problem is when
user clicks on a button the page is re-loaded, however the combo's DataSource
is null. How can I get the combo to keep it's reference to the DataSource
during the re-load? I would like for the current selected item in the combo
to survive the page re-load.

private void Page_Load(object sender, System.EventArgs e)
{
if( !IsPostBack )
{
ArrayList aZips = (ArrayList) (Application["Zips"]);
cboZip.DataSource = aZips;
cboZip.DataBind();
}
}

Nov 18 '05 #2
Sorry I'm not bright. Yes I can add the arraylist to viewstate, I don't see
the difference to what I'm doing now, fetching it from Application. However
I don't get notification that the page is about to be dismissed, so how to
save the current value of the combo?

I would think that if the user clicks on a control, a button in this case,
before anything happens I'd get notified. Even at the script level.

"Sudhakar Sadasivuni[mvp]" wrote:
You can add the arraylist to viewstate on pageload. and for all consequent
loads you can check for the same in ViewState and load. making objects static
also works fine but not recommended.

Sudhakar Sadasivuni
http://one.mvpblog.com
http://www.mugh.net
"Coffee guy" wrote:
I have a combo that gets bound to an ArrayList in Page_Load. Problem is when
user clicks on a button the page is re-loaded, however the combo's DataSource
is null. How can I get the combo to keep it's reference to the DataSource
during the re-load? I would like for the current selected item in the combo
to survive the page re-load.

private void Page_Load(object sender, System.EventArgs e)
{
if( !IsPostBack )
{
ArrayList aZips = (ArrayList) (Application["Zips"]);
cboZip.DataSource = aZips;
cboZip.DataBind();
}
}

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Paolo Losi | last post by:
Hi all, I'm pretty new to the python language so please excuse me if this is FAQ... I'm very glad to be part of the list! :-) I'm looking into a way to implement a generic workflow framework...
3
by: Studio P.M. | last post by:
Dear colleagues, I kindly ask the C# developers community to help me to REALLY understand the Page_Load event, so to REALLY have it under control. Reason for this question is that I cannot...
14
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
3
by: doobdave | last post by:
Hi all, I'm experiencing a rather strange problem: I am coding a web application using VB.net ASP.net and Visual Studio 2003. It's quite a large application, but the problem only occurs on...
0
by: jonelling | last post by:
I am having a problem where the page load event is not being fired for certain user controls that I load dynamically in placeholders. Here is what I'm doing in brief, with full test code supplied...
2
by: John | last post by:
Hi I am using login control with sql server based membership/roles. I have checked the 'remember me' tick box but the login control does not show the username/password when I next come back to...
3
by: Andrew | last post by:
Hello, friends, In a .aspx page, we have a web user control. In both control and .aspx page, we have Page_Load event. My question is: Which event will raised first when rendering this page...
2
by: dkode | last post by:
Hello, I am laying out the architecture for a very large website that will scale to a very large degree. I have a couple of questions before I attempt to go and implement a Broker/Persistence...
0
myusernotyours
by: myusernotyours | last post by:
Hi all, Am trying to create a Java Desktop App that uses Java Persistence in Netbeans. The database is MS Access but I tried with Mysql and got the same error. When I run the app( Create the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.