473,503 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox Question

I added items to a listbox as follows:

Dim datDrivers As New SqlConnection(SQL_CONNECTION_CB)
Dim adpDrivers As New
SqlDataAdapter(MySelectStatement,datDrivers)
adpDrivers.Fill(DriverData, DRIVER_TABLE_NAME)
lstDrivers.DataSource = DriverData.Tables(DRIVER_TABLE_NAME)
lstDrivers.DisplayMember = "Name"
lstDrivers.ValueMember = "DriverID"

I am trying to retrieve the value assigned by this

lstDrivers.ValueMember = "DriverID"

By using a statement like this

Dim strDriverID As String = lstDrivers.SelectedItem.ToString

But all I'm getting is this

System.Data.DataRowView (the value displayed in watches for strDriverID)

What am I doing wrong?

Nov 20 '05 #1
4 897
Hi,
Dim drv as DataRowView = lstDrivers.SelectedItem
Dim strDriverID As String = drv("DriverID")

Ken
-----------------
"Ed Bick" <no******@comcast.net> wrote in message
news:R6********************@comcast.com...
I added items to a listbox as follows:

Dim datDrivers As New SqlConnection(SQL_CONNECTION_CB)
Dim adpDrivers As New
SqlDataAdapter(MySelectStatement,datDrivers)
adpDrivers.Fill(DriverData, DRIVER_TABLE_NAME)
lstDrivers.DataSource = DriverData.Tables(DRIVER_TABLE_NAME)
lstDrivers.DisplayMember = "Name"
lstDrivers.ValueMember = "DriverID"

I am trying to retrieve the value assigned by this

lstDrivers.ValueMember = "DriverID"

By using a statement like this

Dim strDriverID As String = lstDrivers.SelectedItem.ToString

But all I'm getting is this

System.Data.DataRowView (the value displayed in watches for strDriverID)

What am I doing wrong?

Nov 20 '05 #2
Cor
Hi Ed,

Does this do it?
Dim strDriverID As String = lstDrivers.SelectedItem.ToString

Dim strDriverId as String = lstDrivers.SelectedValue.ToString,

I hope this helps?

Cor
Nov 20 '05 #3
Ken,

Bingo, thanks. But please look at my response to your response on the
Datagrid ?

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:#$**************@TK2MSFTNGP11.phx.gbl...
Hi,
Dim drv as DataRowView = lstDrivers.SelectedItem
Dim strDriverID As String = drv("DriverID")

Ken
-----------------
"Ed Bick" <no******@comcast.net> wrote in message
news:R6********************@comcast.com...
I added items to a listbox as follows:

Dim datDrivers As New SqlConnection(SQL_CONNECTION_CB)
Dim adpDrivers As New
SqlDataAdapter(MySelectStatement,datDrivers)
adpDrivers.Fill(DriverData, DRIVER_TABLE_NAME)
lstDrivers.DataSource = DriverData.Tables(DRIVER_TABLE_NAME)
lstDrivers.DisplayMember = "Name"
lstDrivers.ValueMember = "DriverID"

I am trying to retrieve the value assigned by this

lstDrivers.ValueMember = "DriverID"

By using a statement like this

Dim strDriverID As String = lstDrivers.SelectedItem.ToString

But all I'm getting is this

System.Data.DataRowView (the value displayed in watches for strDriverID)
What am I doing wrong?


Nov 20 '05 #4
"Ed Bick" <no******@comcast.net> schrieb
I added items to a listbox as follows:

Dim datDrivers As New SqlConnection(SQL_CONNECTION_CB)
Dim adpDrivers As New
SqlDataAdapter(MySelectStatement,datDrivers)
adpDrivers.Fill(DriverData, DRIVER_TABLE_NAME)
lstDrivers.DataSource =
DriverData.Tables(DRIVER_TABLE_NAME) lstDrivers.DisplayMember =
"Name"
lstDrivers.ValueMember = "DriverID"

I am trying to retrieve the value assigned by this

lstDrivers.ValueMember = "DriverID"

By using a statement like this

Dim strDriverID As String =
lstDrivers.SelectedItem.ToString

But all I'm getting is this

System.Data.DataRowView (the value displayed in watches for
strDriverID)

What am I doing wrong?


Untested: Use lstDrivers.SelectedValue
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5

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

Similar topics

4
2296
by: f_salazar | last post by:
English Version !! Hi !! I have a page with a Form, inside the form I have listbox with 'X' elements. Wend I submit the page, an ASP process inside the page have to read those elements and...
3
6090
by: Stimp | last post by:
I have a listbox of values that I populate from a database. I want the user to be able to re-order the list (by first selecting an item and then clicking 'up' or 'down' buttons) and then save...
8
2340
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
21
2231
by: Bilal Abbasi | last post by:
I realize that you can add items to a list box as objects so you can have access to more than just one property like the itemindex in vb6. Question I have is how do I cause the listbox to show a...
3
8877
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
0
1527
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box...
0
1395
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box...
2
1788
by: dan NY | last post by:
I'm a struggling new VB Applications user that has what may be a simple question, but I've been struggling with it. I'm using a response to a message box YesNo question to cause one of two...
3
1654
by: caracolito1975 | last post by:
Hi to every one!!!! For some time now I'm programing in .NET and I have a question in using ListBox I need to databind a collection to a ListBox. My code is something like this: using...
8
15389
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
0
7198
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
7072
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
7271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7319
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...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.