How to populate dropdown list from database?

Discussion in 'ASP .Net' started by =?Utf-8?B?TWVyZGFhZA==?=, Oct 20, 2004.

  1. 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
    =?Utf-8?B?TWVyZGFhZA==?=, Oct 20, 2004
    #1
    1. Advertising

  2. --
    LUIS ESTEBAN VALENCIA
    MICROSOFT DCE 2.
    MIEMBRO ACTIVO DE ALIANZADEV
    "Merdaad" <> escribió en el mensaje
    news:...
    > 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
    >
    >
    Luis Esteban Valencia, Oct 20, 2004
    #2
    1. Advertising

  3. 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" <> escribió en el mensaje
    news:...
    > 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
    >
    >
    Luis Esteban Valencia, Oct 20, 2004
    #3
  4. 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" <> escribió en el mensaje
    > news:...
    > > 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
    > >
    > >

    >
    >
    >
    =?Utf-8?B?TWVyZGFhZA==?=, Oct 20, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Populate dropdown list

    Mark Goldin, Jul 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    507
    Jeffrey Palermo [MCP]
    Jul 26, 2004
  2. Jim via DotNetMonster.com

    Populate a dropdown list with a variable from a Querystring

    Jim via DotNetMonster.com, Feb 24, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    744
    Malik Asif Joyia
    Feb 24, 2005
  3. Vinay
    Replies:
    2
    Views:
    1,004
    Vinay
    Aug 18, 2005
  4. Replies:
    2
    Views:
    430
  5. Steve Myers
    Replies:
    2
    Views:
    266
    Steve Myers
    Nov 20, 2003
Loading...

Share This Page