Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to populate dropdown list from database?

Reply
Thread Tools

How to populate dropdown list from database?

 
 
=?Utf-8?B?TWVyZGFhZA==?=
Guest
Posts: n/a
 
      10-20-2004
I saw an example of this which talked about assigning valueTextField and
DataTextField. So I have twenty items coming back from the database(I use a
dataadapter), do I need to go thru a loop to assign each item in the Dropdown?
Is there a way to just assign the datasource to a dataset (that's filled
with data)?

Thanks a lot

Merdaad


 
Reply With Quote
 
 
 
 
Luis Esteban Valencia
Guest
Posts: n/a
 
      10-20-2004


--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEV
"Merdaad" <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed)...
> I saw an example of this which talked about assigning valueTextField and
> DataTextField. So I have twenty items coming back from the database(I use

a
> dataadapter), do I need to go thru a loop to assign each item in the

Dropdown?
> Is there a way to just assign the datasource to a dataset (that's filled
> with data)?
>
> Thanks a lot
>
> Merdaad
>
>



 
Reply With Quote
 
 
 
 
Luis Esteban Valencia
Guest
Posts: n/a
 
      10-20-2004
private void cargarProveedores()

{

SqlDataAdapter myadapter = new SqlDataAdapter("select idproveedor,
nombreproveedor from proveedores order by nombreproveedor asc",
sqlConnection1);

DataSet myds = new DataSet();

myadapter.Fill(myds);

comboproveedores.DataSource= myds;

comboproveedores.DataTextField ="nombreproveedor";

comboproveedores.DataValueField = "idproveedor";

comboproveedores.DataBind();

}


--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEV
"Merdaad" <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed)...
> I saw an example of this which talked about assigning valueTextField and
> DataTextField. So I have twenty items coming back from the database(I use

a
> dataadapter), do I need to go thru a loop to assign each item in the

Dropdown?
> Is there a way to just assign the datasource to a dataset (that's filled
> with data)?
>
> Thanks a lot
>
> Merdaad
>
>



 
Reply With Quote
 
=?Utf-8?B?TWVyZGFhZA==?=
Guest
Posts: n/a
 
      10-20-2004
Thanks that worked great.

"Luis Esteban Valencia" wrote:

> private void cargarProveedores()
>
> {
>
> SqlDataAdapter myadapter = new SqlDataAdapter("select idproveedor,
> nombreproveedor from proveedores order by nombreproveedor asc",
> sqlConnection1);
>
> DataSet myds = new DataSet();
>
> myadapter.Fill(myds);
>
> comboproveedores.DataSource= myds;
>
> comboproveedores.DataTextField ="nombreproveedor";
>
> comboproveedores.DataValueField = "idproveedor";
>
> comboproveedores.DataBind();
>
> }
>
>
> --
> LUIS ESTEBAN VALENCIA
> MICROSOFT DCE 2.
> MIEMBRO ACTIVO DE ALIANZADEV
> "Merdaad" <(E-Mail Removed)> escribió en el mensaje
> news:(E-Mail Removed)...
> > I saw an example of this which talked about assigning valueTextField and
> > DataTextField. So I have twenty items coming back from the database(I use

> a
> > dataadapter), do I need to go thru a loop to assign each item in the

> Dropdown?
> > Is there a way to just assign the datasource to a dataset (that's filled
> > with data)?
> >
> > Thanks a lot
> >
> > Merdaad
> >
> >

>
>
>

 
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
Populate 2nd dropdown list based on selecteditem in first with out postback? Vinay ASP .Net 2 08-18-2005 06:15 PM
Populate DropDown list at run-time John Beschler ASP .Net Web Controls 3 08-12-2005 12:36 PM
Populate a dropdown list with a variable from a Querystring Jim via DotNetMonster.com ASP .Net 2 02-24-2005 06:25 AM
Populate dropdown list Mark Goldin ASP .Net 1 07-26-2004 02:31 AM
Edit Mode - How do I populate dropdown in edittemplate from dropdown in another column? Steve Myers ASP .Net Datagrid Control 2 11-20-2003 01:09 PM



Advertisments