Return values string from list box

Rajni.Shekhar
Posted by Rajni.Shekhar under ASP.NET category on | Points: 40 | Views : 1615
public string GetValueFromList(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.Value + ",";
}
}
Lst = Lst.Substring(0, Lst.Length - 1);
}
return Lst;
}

Comments or Responses

Login to post response