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

Help on databinding ?

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


P: n/a
For the listbox set DataTextField and/or DataValueField.

Eliyahu

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:FD**********************************@microsof t.com...
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

Jan 18 '06 #2

P: n/a
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

Jan 18 '06 #3

P: n/a

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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"serge calderara" wrote:
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

Jan 18 '06 #4

P: n/a
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

--
MY ASP.Net tutorials
http://www.openmymind.net/
"DKode" <dk****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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

Jan 18 '06 #5

P: n/a
oh whoopsie,

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

:)

my fault

Jan 18 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.