I have an enumeration in my project and I\'ve created a custom editor template for this enumeration. So, now any model I have with a property with a type of this enumeration, wi
How about the following template:
@model ItemEnumerations.ItemType
@{
var values =
from value in Enum.GetValues(typeof(ItemType)).Cast()
select new { ID = (int)value, Name = value.ToString() };
var list = new SelectList(values , "ID", "Name", (int)Model);
}
@Html.DropDownList("", list)
This way you don't need to manually render and
tags and you are reusing the existing
DropDownList
helper.