473,320 Members | 1,865 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,320 software developers and data experts.

Filling a listbox frustration

I’m trying to populate a listbox with data that comes from my SQL server.
I’ve created the connection, filled the dataset and loaded the data adapter.
Apparently, I’m missing something because after this runs, what is populated
in the listbox is: “System.Data.DataRowView” for each record in my data
adapter.

When I click on one of the rows (which really doesn’t make sense) as I test
the rest of my routine, I’m able to trick it into showing me other data from
that row.

Below is the piece of code that I'm trying to use to load my listbox.

'Fill the data adapter
daEmployeeTree.Fill(dsEmployeeTree, "SuperInfo")

' create data view
Dim dv As DataView = dsEmployeeTree.Tables("SuperInfo").DefaultView
lbxEmployee.DataSource = dv
lbxEmployee.DisplayMember = "SuperInfo"
lbxEmployee.DisplayMember = dv.ToString

Can someone help me fill my listbox with meaningful data? As you can tell,
I’m new to this so any and all help is greatly appreciated.

Thanks,

--
JMorrell
Nov 22 '05 #1
2 2276
You need to bind the data to the listbox
after you assign the fields to it.

lbxEmployee.DataBind()
"JMorrell" wrote:
I’m trying to populate a listbox with data that comes from my SQL server.
I’ve created the connection, filled the dataset and loaded the data adapter.
Apparently, I’m missing something because after this runs, what is populated
in the listbox is: “System.Data.DataRowView” for each record in my data
adapter.

When I click on one of the rows (which really doesn’t make sense) as I test
the rest of my routine, I’m able to trick it into showing me other data from
that row.

Below is the piece of code that I'm trying to use to load my listbox.

'Fill the data adapter
daEmployeeTree.Fill(dsEmployeeTree, "SuperInfo")

' create data view
Dim dv As DataView = dsEmployeeTree.Tables("SuperInfo").DefaultView
lbxEmployee.DataSource = dv
lbxEmployee.DisplayMember = "SuperInfo"
lbxEmployee.DisplayMember = dv.ToString

Can someone help me fill my listbox with meaningful data? As you can tell,
I’m new to this so any and all help is greatly appreciated.

Thanks,

--
JMorrell

Nov 22 '05 #2
Basic syntax to populating a listbox

With ListBox1
.DataSource = "Data Source"
.DataMember = "Table_Name"
.DataTextField = "table_Column_name1" ' This is the text that
will show in listbox
.DataValueField = "table_Column_name2" 'This is the value behind
the text if left out will take on the value of the DataTextField"
.DataBind()
End With
"JMorrell" wrote:
I’m trying to populate a listbox with data that comes from my SQL server.
I’ve created the connection, filled the dataset and loaded the data adapter.
Apparently, I’m missing something because after this runs, what is populated
in the listbox is: “System.Data.DataRowView” for each record in my data
adapter.

When I click on one of the rows (which really doesn’t make sense) as I test
the rest of my routine, I’m able to trick it into showing me other data from
that row.

Below is the piece of code that I'm trying to use to load my listbox.

'Fill the data adapter
daEmployeeTree.Fill(dsEmployeeTree, "SuperInfo")

' create data view
Dim dv As DataView = dsEmployeeTree.Tables("SuperInfo").DefaultView
lbxEmployee.DataSource = dv
lbxEmployee.DisplayMember = "SuperInfo"
lbxEmployee.DisplayMember = dv.ToString

Can someone help me fill my listbox with meaningful data? As you can tell,
I’m new to this so any and all help is greatly appreciated.

Thanks,

--
JMorrell

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JeffOfJerrsey | last post by:
Executing the following code: With ListBox1 .DisplayMember = "UserName" .ValueMember = "UserID" .DataSource = dtUsers End With With ddlUsers .DisplayMember = "UserName"
2
by: JMorrell | last post by:
I’m trying to populate a listbox with data that comes from my SQL server. I’ve created the connection, filled the dataset and loaded the data adapter. Apparently, I’m missing something...
2
by: Petter L | last post by:
I have set up a test program on how to use colletions saved and loaded from a file. It was a part of a other program until this happends. The saving process working fine but it looks like something...
1
by: lance2001 | last post by:
Hi, After viewing the entire Visual Basic 2005 Express Edition for Beginners video series, I have begun building a database driven application that will make use of listbox1 (multi-select)...
1
by: cj | last post by:
This used to work a year ago when I wrote it using SQL Express 2005 on my pc but I've created the database and tables on our production SQL Sever 2000 and it doesn't work What's listed in the...
5
by: markr1000 | last post by:
I must have looked searched in 500+ places that showed up in Google searchs, but not one has an example of what I want to do. I have a Listbox on a User Control because I want to control the...
7
by: Lebbsy | last post by:
I have searched the forum for this but found no match for my search. I would like to have a combo box that does not lookup values from a table but on selecting a value, the value is sent to a...
1
by: mlarsen1982 | last post by:
Hello, I have a quick question regarding filling a list box. Basically I need some assistance for a starting point. I have a form with 4 radio buttons for the user to select, then press next....
2
by: bplantes | last post by:
Hi All, I am new to Access programming and it has been a long time since I have done any programming at all, so I am a bit rusty. I am building a form in Access 2002 that displays a list of...
9
Vini171285
by: Vini171285 | last post by:
Hi, Actually i am filling a list box from database and depending on change in that list box ,the value corresponding to that selected index should come in the textbox,which should come from another...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.