Help on databinding ?

G

Guest

Dear all,

I try to bind a particular column from a dataset to a listbox
What I am doing wrong in the following code ?

There is no error return but listbox is empty

Dim ds As New Data.DataSet


ds = m_DbLayer.GetReels(m_LineName)
ds.Tables(0).TableName = "REELHIST"

Dim dv As New DataView(ds.Tables(0))
Me.lstReelId.DataSource = dv
Me.lstReelId.DataMember = dv.Table.TableName
Me.lstReelId.DataBind()

thnanks for your help
regards
serge
 
D

DKode

try this instead:

Dim dv as New DataView(ds.Tables(0))
Me.lstReelld.DataSource = dv
Me.lstReelld.DisplayMember = "ItemName"
Me.lstReelld.ValueMember = "ItemID"
Me.lstReelld.DataBind()


There should be an error returned because I don't believe .DataMember
is a valid property in the ListBox control
 
G

Guest

ds = m_DbLayer.GetReels(m_LineName)
ds.Tables(0).TableName = "REELHIST"

Dim dv As New DataView(ds.Tables(0))
Me.lstReelId.DataSource = dv
Me.lstReelId.DataMember = dv.Table.TableName

Me.lstReelId.DataTextField = "ReelName" ' column name you want visible
Me.lstReelId.DataValueField ="ReelId" ' column you want for the value

Me.lstReelId.DataBind()


Hope that helps.
Peter
 
K

Karl Seguin [MVP]

DisplayMember and ValueMember are for the WinForm listbox, not the web form
one. DataMember is if you want to bind to a specific named table inside a
dataset.

Karl
 
D

DKode

oh whoopsie,

when i posted the response i wasnt even looking at the newsgroup that
it was posted in

:)

my fault
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top