Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to bind data from database access to drop down list control?

Reply
Thread Tools

How to bind data from database access to drop down list control?

 
 
Joey Liang via DotNetMonster.com
Guest
Posts: n/a
 
      05-13-2005
Hi all,
I am new to ASP.NET, i have met some problems in binding data from a
table of database to a dropdown list control. Anyone knows how to do it?if
possible can rougly write the codes or any tutorials regarding this...Thanx
in advance...

From,
Joey

--
Message posted via http://www.dotnetmonster.com
 
Reply With Quote
 
 
 
 
Eirik Eldorsen
Guest
Posts: n/a
 
      05-13-2005
Here's some code:

private void BindDropdownList()
{
ddlSector.DataSource = Sectors.GetAll();
ddlSector.DataTextField = "Name";
ddlSector.DataValueField = "ID";
ddlSector.DataBind();
}

Call the method BindDropdownList() in PageLoad.
Sectors.GetAll() returns a table. The table have two coloums: Name and ID.


"Joey Liang via DotNetMonster.com" <(E-Mail Removed)> skrev i
melding news:706398a8a5d34af39b870ae316367003@DotNetMonste r.com...
> Hi all,
> I am new to ASP.NET, i have met some problems in binding data from a
> table of database to a dropdown list control. Anyone knows how to do it?if
> possible can rougly write the codes or any tutorials regarding
> this...Thanx
> in advance...
>
> From,
> Joey
>
> --
> Message posted via http://www.dotnetmonster.com



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to Bind Database value to Drop Down List in GridView bjkaledas ASP .Net Web Controls 1 05-17-2007 05:19 PM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
Auto Drop down a Drop Down List xxbmichae1@supergambler.com Javascript 5 11-23-2005 01:35 AM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM
Re: bind drop down list Sonali.NET[MVP] ASP .Net 0 07-13-2003 05:08 PM



Advertisments