|
-
Feb 9th, 2004, 02:51 PM
#1
Thread Starter
PowerPoster
Getting the value of the select items in listbox...should be easy...
Hey all.
I am brain dumping right now, and can't figure this out...
I have a list box that was databound to a table in the form load
(Private dtTeam As DataTable)
Now, I need to loop through the selected items, and add the ValueMember field (NOT the text) of the selected item to another datatable.
Here is what I have came up with...but I don't know how to get the value member.
VB Code:
If lbxTeam.SelectedItems.Count > 0 Then
For i As Integer = 0 To lbxTeam.SelectedItems.Count - 1
drRow = dsData.Tables("Teams").NewRow()
drRow("EntityID") = lbxTeam.SelectedItems.Item(i) '?????????????????
dsData.Tables("Teams").Rows.Add(drRow)
Next
End If
This should be super simple, but I have been asp.net developing for a long while, and don't remember.
-
Feb 9th, 2004, 04:09 PM
#2
Try:
VB Code:
For i As Integer = 0 To lbxTeam.SelectedItems.Count - 1
drRow = dsData.Tables("Teams").NewRow()
drRow("EntityID") = CType(lbxTeam.SelectedItems.Item(i), DataRowView).Item(lbxTeam.ValueMember))
dsData.Tables("Teams").Rows.Add(drRow)
Next
-
Feb 9th, 2004, 07:27 PM
#3
Thread Starter
PowerPoster
Thanks, that was exactly what I needed. Just have to cast it to a dataview....huh..., I don't think I would have headed down that path anytime soon. I understand why now, but I wouldn't have led myself that way...lol.
Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|