Retrieve IEnumerable values from View [duplicate]

1

I have a table / model called ItemPriceFactory:

public class ItemTabelaPreco
{
    public string Nome { get; set; }
    public decimal ValorUnitario { get; set; }
    public int QtdPacote { get; set; }
    public decimal ValorPacote { get; set; }
    public int TabelaPrecoId { get; set; }
}

And another called Trim Table:

public class TabelaPreco
{
    public int Id { get; set; }
    public string Nome { get; set; }
    public decimal Valor { get; set; }
    public IEnumerable<ItemTabelaPreco> ListaItemTabelaPreco { get; set; }
}

In the view of the FastPath table I load the QuickPathItem List without problems:

@model Aplicativo.Models.TabelaPreco

@foreach (var list in Model.ListaItemTabelaPreco)
{
    @Html.Raw(list.Nome)
    @Html.TextBoxFor(Model => list.ValorUnitario)
    @Html.TextBoxFor(Model => list.QtdPacote)
    @Html.TextBoxFor(Model => list.ValorPacote)
}

The problem I have is when it is time to retrieve the values from this list of the view in the edition of TablePreco in the controller after the post, I have tried in several ways and always comes the empty list, the other fields that are not of that list, comes the values correctly:

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(TabelaPreco tabelaPrecoModel)
{
    tabelaPrecoModel.ListaItemTabelaPreco VEM SEMPRE NULL.
}

If anyone can help, thank you in advance.

    
asked by anonymous 27.04.2017 / 14:35

1 answer

-1

Expect to change foeach for a traditional

  @for (int i = 0; i != Model.ListaItemTabelaPreco.Count(); ++i)
 {
@Html.Raw(list.Nome)
@Html.TextBoxFor(m => Model.ListaItemTabelaPreco[i].ValorUnitario)
@Html.TextBoxFor(m=> Model.ListaItemTabelaPreco[i].QtdPacote)
@Html.TextBoxFor(m => Model.ListaItemTabelaPreco[i].ValorPacote)
 }
    
27.04.2017 / 17:21