Thanks but this just produces a string with:
"System.Data.DatRowView, System.Data.DatRowView"
Main Topics
Browse All TopicsHow do you read the values of multiple selected objects in a Listbox whose values are generated from a dbase/dataset?
I would like to read the values of each selected item into a single SCV file with each value seperated with a comma.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Maybe I should explain more. The Listbox has 5 items: Cat1, Cat2, Cat3, Cat4 and Cat5.
I would like to be able to read the selected items into a CSV string, so for example if 1, 2 and 5 where selected, the string would look like this:
"Cat1, Cat2 Cat5"
The items within the listbox are generated by a dataset. If you do this with a hard typed list it works, but when you use the dataset to populate the listbox options then the code produces the snippet in the above post.
I can not seem to be able to get the Cat1, Cat2 etc only the object titles...hope that makes more sense.
Nigel
Hello, OlympicNigel,
OK, I guess that you mean that Cat1, Cat2, Cat3, Cat4 and Cat5 are displaying in the ListBox. (The ListBox actually has (contains) the records from which these values are taken.)
You just need to modify the loop slightly to get the results that you want. I don't know the details of the database records that you have bound to the list, but (for example) if the DisplayMember property in your list were "Field3", then you would modify your loop to match that in the attached snippet.
By the way, you could use the name of any field from the bound record set to get a csv string of those values for the selected records.
Hope that helps.
Cheers,
Randy
Business Accounts
Answer for Membership
by: omegaomegaPosted on 2009-04-24 at 10:34:06ID: 24227361
Hello, OlympicNigel,
I'm not sure what you mean by "values", but perhaps you are just looking for the "SelectedItems" property. If the values were those generated by ToString, you cold do something like the example in the snippet to generate a csv string. Then just write that to whatever file you like.
Cheers,
Randy
Select allOpen in new window