Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 11-Jan-11 21:49pm
Edited 11-Jan-11 23:02pm
Dalek Dave426.3K
v3
Comments
Dalek Dave at 12-Jan-11 5:02am
   
Edited for Readability.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
 
string commaSeperatedData = "data1,data2,data3";
ListBox1.DataSource = commaSeperatedData.Split(',');
ListBox1.DataBind();
  Permalink  
Comments
Dalek Dave at 12-Jan-11 5:02am
   
Good Answer.
Espen Harlinn at 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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 372
1 OriginalGriff 295
2 thatraja 215
3 Emre Ataseven 155
4 Shai Vashdi 125
0 Sergey Alexandrovich Kryukov 8,849
1 OriginalGriff 5,035
2 Peter Leow 3,949
3 Maciej Los 3,535
4 Abhinav S 3,148


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid