I have a ViewModel with two lists of objects. The first one is an editable column, where you can change a numeric value.
After changing the values of the "ListTipos" in the view, it does not arrive with the new values in the controller.
public class ViewModelRetirada
{
...
public IEnumerable<Tipos> ListaTipos { get; set; }
public IEnumerable<Terminais> ListaTerminais { get; set; }
}
The "ListTypes" List in View
@foreach (var item in Model.ListaTipos) {
<tr class="table-active" align="center">
<th scope="row">@item.IdIso</th>
<td>@item.Reservados</td>
<td>@item.QtdeRetirada</td>
<td>@Html.EditorFor(modelItem => item.QtdeDisponivel, new { htmlAttributes = new { @class = "form-control form-control-sm", @type="number"} })</td>
</tr>
}
I am sending the Model as follows:
$("#ExibeTerminais").click(function () {
$.ajax({
url: '/Retirada/ConfirmarRetirada',
type: "post",
data: {tela: @Html.Raw(Json.Encode(Model))},
success: function (result) {
$("#DivListarTerminais").html(result)
},
error: function (result) {
alert("Ocorreu um erro ao tentar recuperar a lista de terminais! \n Tente mais tarde")
}
})
})
When the Model arrives in the Controller, the ListTipos is not with the values changed in the view.
Can anyone help me figure out where I went wrong? Thanks!