我有下一个观点:
@model IEnumerable<L5ERP.Model.BLL.BusinessObjects.MTR_MonthlyTransfer>
@using (Html.BeginForm("ExpenseMonthlyTransferProcessing", "BudgetTransfer", Model.ToList())){
<table class ="divTable">
<tr>
<th>Transferir</th>
<th>
Clave
</th>
<th>
Monto
</th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.CheckBoxFor(x => item.MTR_Bool, new { @class = "checkMTR", @checked = "checked" })
</td>
<td>
@Html.TextBoxFor(x => item.MTR_Key, new {@class = "longInput" })
</td>
<td>
@String.Format("{0:F}", item.MTR_Amount)
</td>
</tr>
}
</table>
}
和我的控制器一样
[HttpPost]
public ActionResult ExpenseMonthlyTransferProcessing(List<MTR_MonthlyTransfer> lstMtr)
{ return View(lstMTR); }
但是当我发布帖子时我的列表为空,如何通过提交按钮发送我的列表?
答案 0 :(得分:1)
您应该将@model
更改为数组(L5ERP.Model.BLL.BusinessObjects.MTR_MonthlyTransfer[]
)或其他实现IList<>
的内容:
@model L5ERP.Model.BLL.BusinessObjects.MTR_MonthlyTransfer[]
@for (var i = 0; i < Model.Length; i ++) {
<tr>
<td>
@Html.CheckBoxFor(x => Model[i].MTR_Bool, new { @class = "checkMTR", @checked = "checked" })
</td>
<td>
@Html.TextBoxFor(x => Model[i].MTR_Key, new {@class = "longInput" })
</td>
<td>
@String.Format("{0:F}", item.MTR_Amount)
</td>
</tr>
答案 1 :(得分:0)
接收FormCollection并手动解析其中的项目
使用F12检查导航器中的帖子,看它是否正在发送您期望的内容。