在我看来,它不工作......
@model PASKAN.Web.Security.Models.User
<p class="lan-name"><label>Language</label>@Html.DropDownListFor(o => o.Language, Enum.GetValues(typeof(Enum)).Cast<Enum>().Select(x => new SelectListItem { Text = x.ToString(), Value = ((int)x).ToString() }))</p>
我的语言模型如下
public enum Language {
English = 0,
Spanish=1,
Latin =3
}
我的控制器看起来像这样
public ActionResult Edit()
{
Models.User user = new User(Convert.ToInt32(User.Identity.Name));
ViewBag.Languages = Enum.GetNames(typeof(Language)).ToList();
return View (user);
}