Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to populate a listbox from databse while values in databse are comma separated.
I have values in the table columns like this "fever, cough".

Please guide me as to how I can populate these items in listbox?
I intend to populate in such a way that each item should appear in separete row in the listbox.

Thanks in Advance
Posted
Updated 11-Jan-11 23:02pm
v3
Comments
Dalek Dave 12-Jan-11 5:02am    
Edited for Readability.

1 solution

You can split the comma seperated values into a string array and you can assign the array as a DataSource to the ListBox.

For example:

MIDL
string commaSeperatedData = "data1,data2,data3";
ListBox1.DataSource = commaSeperatedData.Split(',');
ListBox1.DataBind();
 
Share this answer
 
Comments
Dalek Dave 12-Jan-11 5:02am    
Good Answer.
Espen Harlinn 12-Jan-11 5:22am    
5+ Nice and easy, no fuss

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900