Datasource in a dropdown list

Discussion in 'ASP .Net' started by Paul, Apr 27, 2004.

  1. Paul

    Paul Guest

    Hi

    I have a datasource with 1 table, 100 rows, 1 column. I'm trying to
    populate the drowndown list with the contents of the datasource,

    dd_phys.DataSource = da.ds_phys.Tables("Physical_Office").Rows
    dd_phys.DataBind()

    but this populates my dropdown list with 100 "SYSTEM.DATA.DATAROW"

    I can do the same thing using ths code

    For loopy = 0 To da.ds_phys.Tables("Physical_Office").Rows.Count - 1


    dd_phys.Items.Add(da.ds_phys.Tables("Physical_Office").Rows(loopy).Item(0))

    Next

    But I would prefer to get the datasource and databind to work.

    Any suggestions?
     
    Paul, Apr 27, 2004
    #1
    1. Advertising

  2. Hi, Paul

    Try
    dd_phys.DataSource = ds_phys
    'O
    dd_phys.DataSource = ds_phys.Tables("Physical_Office").DefaultVie
    dd_phys.DataTextField = "FieldText
    dd_phys.DataValueField = "FieldValue
    dd_phys.DataBind(

    Bin Song, MCP
     
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, Apr 27, 2004
    #2
    1. Advertising

  3. Paul

    Scott Hamlin Guest

    I'm not positive, but possibly specifying the fields names that you are
    binding to, like so:

    lstOrig.DataSource = objDS.Tables("Orig").DefaultView
    lstOrig.DataTextField = "Name"
    lstOrig.DataValueField = "ID"
    lstOrig.DataBind()


    "Paul" <> wrote in message
    news:#...
    > Hi
    >
    > I have a datasource with 1 table, 100 rows, 1 column. I'm trying to
    > populate the drowndown list with the contents of the datasource,
    >
    > dd_phys.DataSource = da.ds_phys.Tables("Physical_Office").Rows
    > dd_phys.DataBind()
    >
    > but this populates my dropdown list with 100 "SYSTEM.DATA.DATAROW"
    >
    > I can do the same thing using ths code
    >
    > For loopy = 0 To da.ds_phys.Tables("Physical_Office").Rows.Count - 1
    >
    >
    >

    dd_phys.Items.Add(da.ds_phys.Tables("Physical_Office").Rows(loopy).Item(0))
    >
    > Next
    >
    > But I would prefer to get the datasource and databind to work.
    >
    > Any suggestions?
    >
    >
    >
    >
    >
    >
    >
    >
     
    Scott Hamlin, Apr 27, 2004
    #3
    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. =?Utf-8?B?TWVyZGFhZA==?=
    Replies:
    5
    Views:
    5,867
    neskire
    Nov 7, 2006
  2. =?Utf-8?B?TWVyZGFhZA==?=
    Replies:
    0
    Views:
    356
    =?Utf-8?B?TWVyZGFhZA==?=
    Oct 20, 2004
  3. =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=

    datasource values and dropdown list

    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=, May 6, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    603
    =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?=
    May 6, 2006
  4. =?Utf-8?B?VEpIZXJtYW4=?=

    Getting value of field in dropdown datasource within Formview

    =?Utf-8?B?VEpIZXJtYW4=?=, Jun 19, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    597
    =?Utf-8?B?VEpIZXJtYW4=?=
    Jun 19, 2006
  5. =?Utf-8?B?R29uem9v?=

    AD Datasource for DropDown box

    =?Utf-8?B?R29uem9v?=, Nov 15, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    319
    =?Utf-8?B?R29uem9v?=
    Nov 15, 2006
Loading...

Share This Page