POST表單數(shù)組沒有成功我正在使用C#和.NET Framework 4.5.1開發(fā)ASP.NET MVC 5 Web。我form在一個(gè)cshtml文件中有這個(gè):@model MyProduct.Web.API.Models.ConnectBatchProductViewModel@{
Layout = null;}<!DOCTYPE html><html><head>
<meta name="viewport" content="width=device-width" />
<title>Create</title></head><body>
@if (@Model != null)
{
<h4>Producto: @Model.Product.ProductCode, Cantidad: @Model.ExternalCodesForThisProduct</h4>
using (Html.BeginForm("Save", "ConnectBatchProduct", FormMethod.Post))
{
@Html.HiddenFor(model => model.Product.Id, new { @id = "productId", @Name = "productId" });
<div>
<table id ="batchTable" class="order-list">
<thead>
<tr>
<td>Cantidad</td>
<td>Lote</td>
</tr>
</thead>
<tbody>
<tr>
<td>@Html.TextBox("ConnectBatchProductViewModel.BatchProducts[0].Quantity")</td>
<td>@Html.TextBox("ConnectBatchProductViewModel.BatchProducts[0].BatchName")</td>
<td><a class="deleteRow"></a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5" style="text-align: left;">
<input type="button" id="addrow" value="Add Row" />
</td>
</tr>
</tfoot>
</table>
</div>
<p><input type="submit" value="Seleccionar" /></p>
}
}
else
{
<div>Error.</div>
}<script src="~/Scripts/jquery-2.1.3.min.js"></script><script src="~/js/createBatches.js"></script> <!-- Resource jQuery --> </body></html>這是動(dòng)作方法:[HttpPost]public ActionResult Save(FormCollection form){
return null;}我已經(jīng)檢查了這個(gè)SO答案,這篇文章,但我沒有得到我的代碼工作。
3 回答

拉莫斯之舞
TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個(gè)贊
在Post Methode中,您將收到“MyProduct.Web.API.Models.ConnectBatchProductViewModel”作為參數(shù)。
將現(xiàn)有模型用于Post方法。
為什么你想從你的模型中獲得IEnumerable?只有一個(gè)可用,包括模型中的id。
- 3 回答
- 0 關(guān)注
- 678 瀏覽
添加回答
舉報(bào)
0/150
提交
取消