Use this namespace because here we use regex in the property.
using System.Text.RegularExpressions;
///
/// Gets Or Sets the IDsList.
///
private string IDsList
{
get
{
string IDs = string.Empty;
foreach (ListItem item in lbSample.Items)
{
if (item.Selected)
IDs = IDs + item.Value + ",";
}
IDs = System.Text.RegularExpressions.Regex.Replace(IDs, ",$", "");
return IDs;
}
set
{
foreach (int item in value)
{
if (lbSample.Items.FindByValue(item.ToString()) != null)
lbSample.Items.FindByValue(item.ToString()).Selected = true;
}
}
}
This will automatically return the list of IDs selected in the List box.
No comments:
Post a Comment