I'm extending an Enum and, given the following code, selectListItems
is a generic List of SelectListItems that has all the correct values for my Enum.
The first foreach loop works fine. However, when I create the actual SelectList and pass in selectListItems
, all the values are lost. How can I keep those values intact?
foreach (SelectListItem item in selectListItems)
{
string tex = item.Text;
string val = item.Value;
string sel = item.Selected.ToString();
}
SelectList selectList = new SelectList(selectListItems);
foreach (SelectListItem slid in selectList)
{
string tex = slid.Text;
string val = slid.Value;
string sel = slid.Selected.ToString();
}