Doubt with if inside a Partial View Asp.net mvc

Asked

Viewed 163 times

0

In my view I have:

@if (Model.Count() > 0)
           {

             foreach (var item in Model)
             {
                 @Html.Partial("_FormularioPossibilidade", item)
             }


        }

In Partial: @if (@Html.Displayfor(c => Model.DESCRICAO03) != null) the content and a text,

@model Generico.Dominio.TB_POSSIBILIDADE

@using (Html.BeginForm("GravarRegistro", "Possibilidade", FormMethod.Post))
{
    <div class="container">
        <div class="col-md-3 form-group">
            @Html.HiddenFor(c => Model.IDPOSSIBILIDADE)
            @Html.DisplayFor(c => Model.DESCRICAO01) | R$ @Html.DisplayFor(c => Model.VALOR01)
            @Html.TextBoxFor(c => Model.VALORAPOSTA1, new { placeholder = "0", @class = "form-control", type= "number", })
        </div>

        <div class="col-md-3 form-group">
            @Html.DisplayFor(c => Model.DESCRICAO02) | R$ @Html.DisplayFor(c => Model.VALOR02)
            @Html.TextBoxFor(c => Model.VALORAPOSTA2, new { placeholder = "0", @class = "form-control", type = "number" })
        </div>

        @if (@Html.DisplayFor(c => Model.DESCRICAO03) != null)
        {
        <div class="col-md-3 form-group">
            @Html.DisplayFor(c => Model.DESCRICAO03) | R$ @Html.DisplayFor(c => Model.VALOR03)
            @Html.TextBoxFor(c => Model.VALORAPOSTA3, new { placeholder = "0", @class = "form-control", type = "number" })
        </div>
        }

    </div>
}

1 answer

0


 @if(Model.DESCRICAO03!= string.Empty)
    {
    <div class="col-md-3 form-group">
        @Html.DisplayFor(c => Model.DESCRICAO03) | R$ @Html.DisplayFor(c => Model.VALOR03)
        @Html.TextBoxFor(c => Model.VALORAPOSTA3, new { placeholder = "0", @class = "form-control", type = "number" })
    </div>
    }

Browser other questions tagged

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