How to create comma separated string from selected items in a list box?

The below code will help you to get the comma separated value from a selected items in a list box,




string lstbxItems = "";

foreach(ListItem li in lstbox.Items) //lstbox is ID of ListBox
{
if(li.Selected == true)
{
if(lstbxItems == "")
{
lstbxItems = li.Value;
}
else
{
lstbxItems = lstbxItems + "," + li.Value;
}
}
}


Comments

Author: Bunty24 Feb 2010 Member Level: Gold   Points : 2

Hi,

Can you please explain the points system?

Why I got 5 points for this while others are getting 10 or 15 or 40 points?

I need reasons for this?

Author: Abhay Kumar Raut24 Feb 2010 Member Level: Gold   Points : 2

Hi bunty,

That depends upon the resource.That resource isworthy enough to get that amount of point.Yesterday i submitted a poll about this point system by rating.Check this one of my resource
http://www.dotnetspider.com/resources/36516-Validation-with-jQuery.aspx

I got only 2 points.I am also confused.Ok bunty I will make it to 6.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: