Get Items from list as a string

Rajni.Shekhar
Posted by Rajni.Shekhar under ASP.NET category on | Points: 40 | Views : 954
public string GetItemFromList(ListBox LstBox)
{
string Lst = "";
if (LstBox.SelectedIndex > -1)
{
// Iterate through the Items collection of the ListBox and
// display the selected items.
foreach (ListItem item in LstBox.Items)
{
if (item.Selected)
{
Lst += item.Text + ",";
}
}
Lst = Lst.Substring(0, Lst.Length - 1);
}
return Lst;
}

Comments or Responses

Login to post response