【发布时间】:2018-12-15 05:27:26
【问题描述】:
我正在尝试将视图的表值返回到控制器以保存在 db 上,但我一直为空。我可以毫无问题地发布值并将它们绑定到视图。
我不明白为什么,我使用的是服务器端视图模型。
有什么办法可以做到吗?
查看:
@model IEnumerable<MultiEdit.Models.TableViewModel>
@using (Ajax.BeginForm("Save", "UUTs", new AjaxOptions
{
HttpMethod = "Post",
}, new { id = "tableForm" }))
{
@Html.AntiForgeryToken()
<div class="row" style="padding-top:10px;">
<div class="col-lg-12">
<table class="table table-bordered table-striped ">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.IsChassis)
</th>
<th>
@Html.DisplayNameFor(model => model.Justification)
</th>
</tr>
</thead>
<tbody id="tblMultiEdit">
@foreach(var item in Model)
{
<tr>
<td>
@Html.CheckBoxFor(modelItem => item.CheckIsChassis)
</td>
<td>
@Html.EditorFor(modelItem => item.Justification)
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
控制器:
public void Save(IEnumerable<TableViewModel> vm)
{
DoSomething();
}
【问题讨论】:
标签: ajax asp.net-mvc ienumerable