By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,886 Members | 1,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,886 IT Pros & Developers. It's quick & easy.

How to populate dropdown list from database?

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a


--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 2.
MIEMBRO ACTIVO DE ALIANZADEV
"Merdaad" <Me*****@discussions.microsoft.com> escribió en el mensaje
news:5A**********************************@microsof t.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

Nov 18 '05 #2

P: n/a
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" <Me*****@discussions.microsoft.com> escribió en el mensaje
news:5A**********************************@microsof t.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

Nov 18 '05 #3

P: n/a
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" <Me*****@discussions.microsoft.com> escribió en el mensaje
news:5A**********************************@microsof t.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


Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.