0

Question:

This is my enum and and I am using it in drop-down in MVC5 while creating the project and displaying this status on project details page.But these display name are working properly in drop-down list but in details page it is showing the original value e.g In_Progress.How to work with display name?

Code:

public enum status
{
[Display(Name="In Progress")]
In_Progrss,

[Display(Name="Completed")]
Completed
}
Asha B.
  • 83
  • 12
  • Are you using `@Html.EnumDropDownListFor()`in your view? –  Jan 28 '16 at 03:13
  • yup.I'm using it in view it is working fine in drop down list but when i'm trying to show the details of project then it is showing In_Progress rather than In Progress. :( – Asha B. Jan 28 '16 at 03:22
  • You will need to create your own extension method to return the value of the `DisplayName` attribute. The [answers here](http://stackoverflow.com/questions/13099834/how-to-get-the-display-name-attribute-of-an-enum-member-via-mvc-razor-code) will help you get started (see the `public static string GetDisplayValue(T value)` method in the accepted answer) –  Jan 28 '16 at 03:31

0 Answers0