Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / October 2003

Tip: Looking for answers? Try searching our database.

Bind only once (DropDownList)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kaasztelann - 27 Sep 2003 06:55 GMT
I have a DropDownList on my Webform. This list is bounded to DataSet which
is populate from database.
When load the form, list is filled and all is OK. The problem is, that the
list is small (only 3 items), so I want to preserve the list by ViewState
(it is on), and want the list to be populated from database only first time
(when IsPostBack==false).
How to bind this control only once? I have 1 solution which I don't like:

   If I don't use Page.DataBind(), but <each control>.DataBind(),
   then can then do if(!IsPostBack)MyList1.DataBind();
   It works, but I don't like it, because I have a lot of controls on form.

Is there any other solution?

Please, help
Gorbi
name - 27 Sep 2003 07:33 GMT
I will treat your "Webform" stuff in any case.

I will treat it like the Viruses" that surround your post.

----------------

And I take pride in saying:

I am not an Idiot.

=============================

Good luck

> I have a DropDownList on my Webform. This list is bounded to DataSet which
> is populate from database.
[quoted text clipped - 12 lines]
> Please, help
> Gorbi
kaasztelann - 01 Oct 2003 11:06 GMT
Are you OK?

> I will treat your "Webform" stuff in any case.
[...]
kaasztelann - 01 Oct 2003 11:09 GMT
> I will treat your "Webform" stuff in any case.
[...]
Do you feel well?
John Saunders - 27 Sep 2003 13:25 GMT
> I have a DropDownList on my Webform. This list is bounded to DataSet which
> is populate from database.
[quoted text clipped - 7 lines]
>     then can then do if(!IsPostBack)MyList1.DataBind();
>     It works, but I don't like it, because I have a lot of controls on form.

if (!Page.IsPostBack)
{
   // Load data from database and then call
   DataBind();
}

Signature

John Saunders
Internet Engineer
john.saunders@surfcontrol.com

kaasztelann - 01 Oct 2003 11:05 GMT
> > I have a DropDownList on my Webform. This list is bounded to DataSet which
> > is populate from database.
[...]

> if (!Page.IsPostBack)
> {
>     // Load data from database and then call
>     DataBind();
> }
It is not good solution, bacause there are other controls which must be
populated from DB every time (at each postback).

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.