Suelen Marinho
Suelen Marinho

Reputation: 3

'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage<TModel>.Model'

I am having a problem in my code and I can not use a list inside a class in a foreach, has anyone had a similar problem? Follows the code:

Model

public class Detalhes_Pedido
{
    public Pedidos Pedido { get; set; }
    public Pedidos_Endereco Pedido_Endereco { get; set; }
    public Pedidos_Status Pedido_Status { get; set; }
    public List<Pedidos_Produtos> Pedido_Produto { get; set; }
    public List<Produtos> Produto { get; set; }
    public Clientes Cliente { get; set; }
    public Metodos_Entrega Metodo_entrega { get; set; }
    public Metodos_Pagamento Metodos_Pagamento { get; set; }
}

View

@model Ecommerce.Models.Repository.Pedido_Repository.Detalhes_Pedido
@Html.AntiForgeryToken()
@Html.HiddenFor(model => model.Pedido.ID)
<div class="module_content">
  <div class="ModuleConteiner">
    @Html.ValidationSummary(true)
    <table class="QuatroColumnTable">
      <tr>
        <td colspan="2">
          <h3>Dados da Transação</h3>
          <br />
        </td>
      </tr>
      <tr>
        <td>
          @Html.LabelFor(model => model.Pedido.ID, "Número do Pedido: ")
          <br />
        </td>

here is where the problem occurs:

        <td>
          @Html.DisplayFor(model => model.Pedido.ID)
          <br />
        </td>
      </tr>
      <tr>
        <td>
          @Html.LabelFor(model => model.Pedido, "Peso total da compra: ")
        </td>
        <td>
          **@foreach (var item in model.Produto)
             { 
             }**
        </td>
      </tr>
    </table>

What can be happening?

Upvotes: 0

Views: 2990

Answers (1)

Paddy
Paddy

Reputation: 33857

You need a capital M in Model:

    @foreach (var item in Model.Produto)
                    { 
                    }

Upvotes: 1

Related Questions