I have an enum
I want to turn into a DropDownList
for registration purposes I am currently using:
@Html.DropDownListFor(InputModel => InputModel.Input.UserProffesion.GetValues(typeof(Mindfull8User.Proffesion)).Cast<string>())
And I am getting an error:
Severity Code Description Project File Line Suppression State Error (active) CS0176 Member 'Enum.GetValues(Type)' cannot be accessed with an instance reference; qualify it with a type name instead Mindfull8 c:\Users\User\source\repos\Mindfull8\Mindfull8\Areas\Identity\Pages\Account\Register.cshtml 53
How do I solve this? Thanks
CodePudding user response:
Did you try to use the HtmlHelper.GetEnumSelectList Method that returns a select list for the given type?
For example, if the Proffesion
is the given enum
type:
@Html.DropDownListFor(InputModel=> InputModel.UserProffesion, Html.GetEnumSelectList<Proffesion>(), optionLabel: "Select a value")