I have trawled the internet but I cannot find a solution to the following problem.
I have a ListBox control that gets populated with a list of values from a SQL Server database table on FormLoad.
This allows the user to select multiple values and these can be submitted into the SQL Server database column as comma-delimted values.
Problem is that I would like the user to allow the editing of these submitted values from the same ListBox control.
Therefore I would like to show the user the values that are pulled from the database as selected values in the ListBox and NOT populate the ListBox with those values as the ListBox has been populated already with set values on FormLoad.
I am trying this but its not working -
foreach (ListItem li in lst_subspeciality.Items)
{
foreach (string sqlitem in dt.Rows[0]["SubSpeciality"].ToString().Split(','))
{
if (li.Text == sqlitem.ToString())
{
li.Selected = true;
}
}
}
Any help is much appreciated.
Thanks.