Convert List To IEnumerable
Answer :
Maybe try this? (untested)
ViewBag.AvaiableEnums = dynamicTextEnumsAvaiable.Select(x =>
new SelectListItem()
{
Text = x.ToString()
});
You could do the following
ViewBag.AvaiableEnums = new SelectList(dynamicTextEnumsAvaiable)
See http://msdn.microsoft.com/en-us/library/system.web.mvc.selectlist(v=vs.118).aspx
You can maybe use a Linq statement to convert it
IEnumerable<SelectListItem> myCollection = dynamicTextEnumsAvaiable
.Select(i => new SelectListItem()
{
Text = i.ToString(),
Value = i
});
Comments
Post a Comment