HighTechTalks DotNet Forums  

How do I keep a control from initializing every time?

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss How do I keep a control from initializing every time? in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Carter
 
Posts: n/a

Default How do I keep a control from initializing every time? - 09-24-2004 , 11:27 AM






I have a header control at the top of my default page. On this control
there are 4 buttons, each one displays a corresponding panel.

There also is a drop down list with a list of counties. The list of
counties is filled from a dataset when the page loads. The user selects a
county, and then selects a button. Each time a button is selected, the
control reloads and the county selection is lost and is filled again, not
only taking a lot of time but losing the user's selection. How do I stop
the drop down list from loading each time? I have tried using If
ispostback, then FillCountyList, but it doesn't seem to matter. Thanks.



Reply With Quote
  #2  
Old   
John Saunders
 
Posts: n/a

Default Re: How do I keep a control from initializing every time? - 09-24-2004 , 01:45 PM






"Carter" <eagletender2001 (AT) yahoo (DOT) com> wrote

Quote:
I have a header control at the top of my default page. On this control
there are 4 buttons, each one displays a corresponding panel.

There also is a drop down list with a list of counties. The list of
counties is filled from a dataset when the page loads. The user selects a
county, and then selects a button. Each time a button is selected, the
control reloads and the county selection is lost and is filled again, not
only taking a lot of time but losing the user's selection. How do I stop
the drop down list from loading each time? I have tried using If
ispostback, then FillCountyList, but it doesn't seem to matter. Thanks.
First of all, I suggest you reproduce a simpler version of this problem,
like a form with one dropdown and one button, which doesn't do anything.

Second, it sounds like you are refilling the DropDownList on every postback.
Your Page_Load should probably look something like this:

private void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// Load your datasets
DataBind(); // Binds loaded data to all controls
}
else
{
// You shouldn't need to load anything since data were saved in
ViewState
}
}

-----
John Saunders




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.