Display an Enumdropdownlistfor as a condition

Asked

Viewed 29 times

1

How to present a EnumDropDownListFor as a condition? For example, if the user wishes to inform his or her sexual orientation Enum is presented. Otherwise it is not presented.

1 answer

0


I would do so:

@if (UsuarioNaoQuerApresentarOrientacaoSexual)
{
    @Html.Hidden(model => model.OrientacaoSexual, OrientacaoSexual.NaoInformado)
}
else
{
    @Html.EnumDropDownListFor(model => model.OrientacaoSexual, ...)
}
  • This User Who Rapresents Rientacaosexual is a bool type ?

  • Yes, it may also be a condition that returns bool.

  • Could you give me a full example

Browser other questions tagged

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