我得到了一份清单:
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"/>
}
请帮我!