How can I set the selectedvalue property of a SelectList after it was instantiated without a selectedvalue;
SelectList selectList = new SelectList(items, "ID", "Name");
If you have your SelectList object, just iterate through the items in it and set the "Selected" property of the item you wish.
foreach (var item in selectList.Items)
{
if (item.Value == selectedValue)
{
item.Selected = true;
break;
}
}
Or with Linq:
var selected = list.Where(x => x.Value == "selectedValue").First();
selected.Selected = true;