I have the following view model:
public class BudgetTypeSiteRowListViewModel
{
public virtual int BudgetTypeSiteID { get; set; }
public virtual string SiteName { get; set; }
public virtual BudgetTypeEnumViewModel SiteType { get; set; }
}
With the following enum:
public enum BudgetTypeEnumViewModel
{
[Display(Name = "BudgetTypeDaily", ResourceType = typeof (UserResource))] Daily = 1,
[Display(Name = "BudgetTypeRevision", ResourceType = typeof (UserResource))] Revision = 2
}
And the following view for listing my items:
@model IEnumerable<BudgetTypeSiteRowListViewModel>
<table>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(m => item.SiteName)</td>
<td>@Html.DisplayFor(m => item.SiteType)</td>
</tr>
}
</table>
The problem is that my items listed are not in the right culture. I have ‘Daily’ or ‘Revision’ where I should have ‘Journalier’ or ‘Dagelijkse’ or ‘Révision’ or ‘Revisie’.
How can I have my SiteType in the right culture (provided from my enum)?
Thanks.
You have to write an extension method that use reflection to get the enume type of your property
From the view you will get th value like this
I hope it helps