我想知道如何将表数据发布到控制器中。现在,我可以创建数据表,但是我不知道如何将数据从数据表传递到控制器。请!!向我显示正确的方向。有人可以告诉我该怎么做吗?。
查看
<table id="gridview">
<tbody>
<tr>
<th><h5>SrNo</h5></th>
<th><h5>stock no</h5></th>
<th><h5>stock name</h5></th>
<th><h5>UM</h5></th>
<th><h5>Balance</h5></th>
<th><h5>Purchase Price</h5></th>
<th><h5>Quantity</h5> </th>
<th><h5>Amount</h5></th>
<th></th>
</tr>
</tbody>
<tr></tr>
</table>
jQuery
$("#txtQuantity").blur(function () {
var a, b, c , d, e;
a = $("#ddlStock").val(),
b = $("#txtPrice").val(),
c = $("#txtQuantity").val(),
d = b * c;
$.ajax({
type: "GET",
url: "/PurchaseOrder/GetStockData?id=" + a,
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
success: function (data) {
$('#gridview tr:last').after('<tr><td><h5>' +1 + '</h5></td><td><h5>'
+ data.StockNo + '</h5></td><td><h5>' + data.Name + '</h5></td><td><h5>'
+ data.UOM + '</h5></td><td><h5>'+0+'</h5></td><td><h5>'+b+'</h5></td><td><h5>'
+ c + '</h5></td><td><h5>' + d + '</h5></td></tr>');
},
error: function (xhr, status, error) {
alert(xhr.responseText);
}
});
});
控制器
public ActionResult GetStockData(string id)
{
StockDM data = db.StockDMs.Find(id);
StockVM inputVM = new StockVM()
{
ID = data.ID,
StockNo = data.StockNo,
Name = data.Name,
UOM = data.UOM,
//CreatedUserID = data.CreatedUserID,
//CreatedDate = data.CreatedDate,
//TS = data.TS,
//UpdatedUserID = data.UpdatedUserID,
//UpdatedDate = data.UpdatedDate,
//Active = data.Active,
};
return Json(inputVM, JsonRequestBehavior.AllowGet);
}