POST表單數(shù)組沒有成功我正在使用C#和.NET Framework 4.5.1開發(fā)ASP.NET MVC 5 Web。我form在一個cshtml文件中有這個:@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>這是動作方法:[HttpPost]public ActionResult Save(FormCollection form){
return null;}我已經檢查了這個SO答案,這篇文章,但我沒有得到我的代碼工作。
3 回答

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