I have an Enum with Display Description attribute,

public enum CSSColours
        [Display(Description = "bg-green")]

        [Display(Description = "bg-blue")]

Now I want to bind this Enum to a DropDownlist, showing the Enum value (Green, Blue) in the Dropdown item display text and Description as the item Value (bg-green, bg-blue).

When I bind the Dropdown with EnumDropDownListFor helper method

@Html.EnumDropDownListFor(c => dm.BgColor)

It sets the item value to Enum value (0, 1), and couldn't find a way to set the value to Display Description.

How can I set the value to Enum Display Description attribute?

Related posts

Recent Viewed