Using enum for dropdown list in ASP.NET MVC Core

后端 未结 8 1196
你的背包
你的背包 2021-01-31 06:51

I\'m trying to create a dropdown list with an enum property in ASP.NET MVC Core using the tag helper in a Razor view:

Here is the model:

public class Per         


        
8条回答
  •  既然无缘
    2021-01-31 07:36

    GenderType is your property name, not the Enum type. The GetEnumSelectList method expects you to give it the type of the Enumeration, not the name of the property in your model.

    Try this:

    Html.GetEnumSelectList()
    

提交回复
热议问题