How do you create a dropdownlist from an enum in ASP.NET MVC?

后端 未结 30 1915
不知归路
不知归路 2020-11-21 16:36

I\'m trying to use the Html.DropDownList extension method but can\'t figure out how to use it with an enumeration.

Let\'s say I have an enumeration like

30条回答
  •  时光说笑
    2020-11-21 17:03

    You can also use my custom HtmlHelpers in Griffin.MvcContrib. The following code:

    @Html2.CheckBoxesFor(model => model.InputType) 
    @Html2.RadioButtonsFor(model => model.InputType)
    @Html2.DropdownFor(model => model.InputType)

    Generates:

    enter image description here

    https://github.com/jgauffin/griffin.mvccontrib

提交回复
热议问题