1

I am trying to populate a drop down list using an enum with MVC4. I have the following enum with a Display attribute:

public enum PlatformEnum
{
    [Display(Name = "--- Please Select ---")]
    Undefined = 0,
    [Display(Name = "Android")]
    Android = 1,
    [Display(Name = "iOS")]
    iOS = 2
}

In my view I have the following drop down list:

@Html.DropDownListFor(model => model.Platform, Model.DropDownPlatform)

However, the display values in the drop down list are:

Undefined
Android
iOS

I need Undefined to display as --- Please Select ---. Is this possible using display attributes?

Mike Baxter
  • 6,868
  • 17
  • 67
  • 115
  • Refer the second highest voted answer [here](http://stackoverflow.com/questions/388483/how-do-you-create-a-dropdownlist-from-an-enum-in-asp-net-mvc?answertab=votes#tab-top) –  Jan 12 '16 at 11:49
  • refer this :http://stackoverflow.com/questions/30525359/how-to-display-user-friendly-name-from-enum-in-dropdownlist-in-mvc-view – Ehsan Sajjad Jan 12 '16 at 12:05

0 Answers0