我有一个视图,内部我正在生成一个列表,但我无法成功将其传递给控制器而没有字段为null:
我的观点代码:
@using (Html.BeginForm("AddFOP", "Revenue", null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<table class="grid" style="margin-top: 15px">
<thead>
<tr>
<th>FOP</th>
<th>ORGN</th>
<th>PROGRAM</th>
<th>PERCENTAGE</th>
<th></th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < Model.editBillingFOPList.Count;i++ )
{
<tr>
<td>@Html.TextBox("FOPList[" + @i + "].Fund",
Model.editBillingFOPList[i].Fund)</td>
<td>@Html.TextBox("FOPList[" + @i + "].ORGN",
Model.editBillingFOPList[i].ORGN)</td>
<td>@Html.TextBox("FOPList[" + @i + "].Program",
Model.editBillingFOPList[i].Program)</td>
<td>@Html.TextBox("FOPList[" + @i + "].Percentage",
Model.editBillingFOPList[i].Percentage)</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
这是控制器:
[HttpPost]
public ActionResult AddFOP(List<BillingFOPModel> FOPList)
{
return View();
}
Run Code Online (Sandbox Code Playgroud)
我的FOPList显示计数为1,如果我在调试模式下展开它,它会显示模型列表但是具有空值 - 任何想法?
我的型号:
public class …
Run Code Online (Sandbox Code Playgroud)