How to get string from Enum on an ASP.MVC grid

Asked

Viewed 139 times

1

I have the following:

public enum RegiaoEnum
{
    CENTRO = 1,
    NORTE = 2,
    SUL = 3,
    SUDESTE = 4,
    CENTROOESTE = 5   
}

And the following View:

@using MeuDominio.Enums;
<div class="animate">
<table ng-table="vm.DadosParams">
    <tr ng-repeat="row in $data" >
        <td class="text-center col-md-3" sortable="'Nome'" data-title="'NOME'">{{row.Nome}}</td>
        <td class="text-center col-md-2" sortable="'Data'" data-title="'DATA'">{{row.Data}}</td>
        <td class="text-center col-md-2" sortable="'Regiao'" data-title="'REGIÃO'">@{{row.Data}}</td>
    </tr>
</table>

What is needed is to display the description of the Enum in the column Region (Center, North...) instead of the value of the numerical value.

1 answer

-1

@using MeuDominio.Enums;
@Enum.Getname(typeof(Regiaoenum), Regiaoenum.CENTRO)
  • Why did you deny my answer? The above example works perfectly...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.