Table within View

0

I'm putting a table inside the Edit view.

Edit View (Contract)

@if (Model.ContratoParcela.Any())
{
    <table class="table parcela-lista">
        @foreach (var parcela in Model.ContratoParcela)
        {
            <tr>
                <th>
                    <a href="#" data-contratoid="@parcela.id_Contrato" data-toggle="modal" data-target="#ModalParcelaEdit">@parcela.valor</a>
                </th>
            </tr>
        }
    </table>
}

But @if is red, underlined.

I want to get the information from the ContractParcela table and display it in the Edit view that comes from the Contract table.

I get this error:

  

Unexpected "if" keyword after "@" character. Once inside code, you do not need to prefix constructs like "if" with "@".

    
asked by anonymous 26.04.2017 / 03:50

1 answer

1

Apparently you're already inside a block covered by @. You can: Being in a situation like this:

@{
  if(true) { }
}

Or so:

@if(true) {
  if (true) { }
}

In both cases you already have an @ around the if, so you do not need to put another one.

    
26.04.2017 / 18:34