I am new to MVC. I created a simple dropdown list using the following code
Model:
public enum weltype
{
Physical = 1,
Career =2
}
controller:
IEnumerable<weltype> Wellbeings = Enum.GetValues(typeof(weltype))
.Cast<weltype>();
model.WellList = from welbeing in Wellbeings
select new SelectListItem
{
Text = welbeing.ToString(),
Value = ((int)welbeing).ToString()
};
return View(model);
view:
@Html.LabelFor(model => model.WellbeingID)
@Html.DropDownListFor(model => model.WellbeingID, Model.WellList)
my problem here is i need to get the enum values from the database using linq or whatever feasible. What is the easiest way to do it?