我有一个列表:我将它传递给这一观点从View传递整个模型回Controller
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");
}
}
但是我坠落错误erably因为“项目”中的回传回来的空
我是猜的东西是错误的形式
@using (Html.BeginForm("CargarRecibidos", "Recepcion"))
{
<input class="btn" name="Guardar" type="submit" value="Guardar"/>
}
请帮帮我!
好了,现在一切都IEnumerable的,但还是同样的问题。 – Milo
您是否在浏览器开发人员工具中看到实际正在发布的内容?也可以尝试在你的Html表单助手中添加参数FormMethod.Post。 –
不,我正在使用铬,我不知道如何查看发布的数据。 – Milo