Re: How to populate dropdown list from database?

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Luis Esteban Valencia (luisvalen_at_haceb.com)
Date: 10/20/04


Date: Wed, 20 Oct 2004 11:32:52 -0500

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" <Merdaad@discussions.microsoft.com> escribió en el mensaje
news:5A13C0C3-A452-46EA-8403-C503241205B1@microsoft.com...
> 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
>
>