473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help on databinding ?

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
5 1044
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
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

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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: CGuy | last post by:
Hi, I have an ASPX page which has a datagrid and this datagrid is bound to a Custom Collection. sample code this.DataGrid1.DataSource = UserManager.Users; this.DataGrid1.DataBind();
3
by: Lloyd Sheen | last post by:
I have several apps that use a roll your own approach, but I am embarking on a project which will not allow that with the time constraints. I have gened up a little app to try the databinding...
3
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
4
by: Ben | last post by:
Hi, I'm using images in my menu control. I have my menu setup based on this example: http://msdn2.microsoft.com/en-US/library/system.web.ui.webcontrols.menuitembinding.imageurlfield(VS.80).aspx ...
2
by: hwiechers | last post by:
I have two drop down lists on a page. Each one is hooked up to a separate SqlDataSource. The second data source has a ControlParameter set to the selected value of the first drop down. When I set...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
3
by: Ken Foskey | last post by:
I am a new VS and C# developer with 20 plus years programming experience and I am finding the database stuff incredibly frustrating. I have read programming c# 3.0 pretty much cover to cover, ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.