Datasource in a dropdown list

P

Paul

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?
 
G

Guest

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
 
S

Scott Hamlin

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()
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top