私は次のリストを手に入れました:
public class Items
{
public String Nro_Item { get; set; }
public Sucursal Sucursal { get; set; }
public Areas Area { get; set; }
public Sectores Sector { get; set; }
public bool ID_Estado { get; set; }
}
私はそれをこのビューに渡します:
@using ClientDependency.Core.Mvc
@model IEnumerable<TrackingOperaciones.Controllers.Items>
@{
ViewBag.Title = "Ver Items";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<br/>
@using (Html.BeginForm("CargarRecibidos", "Recepcion", FormMethod.Post))
{
<table class="table table-striped table-bordered table-condensed">
<tr>
<th>
Numero
</th>
<th>
Sucursal
</th>
<th>
Area
</th>
<th>
Sector
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Nro_Item)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sucursal.descripcion)
</td>
<td>
@Html.DisplayFor(modelItem => item.Area.descripcion)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sector.Descripcion)
</td>
<td>
@Html.CheckBoxFor(modelItem => item.ID_Estado)
</td>
</tr>
}
</table>
<p>
<input class="btn" name="Guardar" type="submit" value="Guardar"/> |
@Html.ActionLink("Volver al listado de Recepción", "Index")
</p>
}
すべてが正常になるまで:問題は、次のように処理するために、コントローラーでチェックされた値を使用してモデル全体を取得することです。
[HttpPost]
public ActionResult CargarRecibidos(IEnumerable<Items> items)
{
if (ModelState.IsValid)
{
//do something here
}
return RedirectToAction("Index");
}
}
しかし、ポストバックで「アイテム」が空に戻ったので、私は惨めに落ちています
フォームに何か問題があると思います
@using (Html.BeginForm("CargarRecibidos", "Recepcion"))
{
<input class="btn" name="Guardar" type="submit" value="Guardar"/>
}
私を助けてください!