我有一个包含大量行的webgrid,每行都有一个复选框。如果我选择10行,我可以将数据推送到 我在控制器中的方法并更新数据库。一旦选择的行超过20,则没有任何反应。我不能 走进我的方法。我可以通过json传递限制吗?你觉得怎么回事?
这是我的jquery代码
$('#MultipleAcctAssignSubmit').click(function () {
var routeselected = $('#ddlroutes :selected').val();
var repsselected = $('#ddlreps :selected').val();
var routeselectedText = $('#ddlroutes :selected').text();
var repsselectedText = $('#ddlreps :selected').text();
var branchcode = $("#ddlDropDownList option:selected").text();
var values = [];
$("#container-grid input[name=CatalogOrderId]:checked").each(function () {
row = $(this).closest("tr");
if (routeselected == "") {
//routeselected = $(row).find("td div.RouteId").text();
//routeselected = $(".routeId").val();
routeselected = 0;
}
if (repsselected == "") {
//repsselected = $(row).find("td div.primrep").text();
//repsselected = $(".PrimaryRepId").val();
repsselected = 0;
}
values.push({
CatalogOrderId: $(row).find("input[name=CatalogOrderId]").val(),
RouteId: routeselected,
Primaryrep: repsselected,
Isvalidated: "Assigned"
});
});
console.log(values);
if (values.length < 1) {
ShowDialogBox('Selection of rows', 'No records have been selected. Please select the record(s) you wish to assign.', 'Ok', '', 'GoToAssetList', null);
return;
}
/* Do some stuff with the values collected */
var things = JSON.stringify({ 'CatalogSelectedOrders': values });
$.get('@Url.Action("SubmitCatalogOrders", "Home")', { 'values': things, 'strBranchcode': branchcode }, function(result) {
$('#scrolltable').html(result);
});
});
这是我在控制器中的方法
public ActionResult SubmitCatalogOrders(string values, string strBranchcode)
{
Grabpartialviewdata objcatsubmit = new Grabpartialviewdata();
string stripOutBranchName = string.Empty;
stripOutBranchName = strBranchcode.Substring(0, 3);
string status = string.Empty;
List<Catalogorder> cleanedData = null;
try
{
var stripOffObjectName = JObject.Parse(values)["CatalogSelectedOrders"];
cleanedData = JsonConvert.DeserializeObject<List<Catalogorder>>(stripOffObjectName.ToString());
status = _edmDataService.ProcessWriteAssingedRowsToDb(cleanedData, stripOutBranchName);
ViewData["SelectList"] = HttpContext.Session["SelectList"] ?? new List<Int64>();
if (status == "success")
{
objcatsubmit = _edmDataService.GetPartialViewData(stripOutBranchName);
}
}
catch (Exception ex)
{
logger.Error(ex);
}
return PartialView("_Edmcatorderdetails", objcatsubmit);
}
答案 0 :(得分:2)
您的代码正在使用SQL2014
方法进行GET调用。 GET调用通过查询字符串发送数据并具有限制。
您应该考虑使用在请求正文中发送数据的POST调用。您可以使用jquery $.get
方法。
$.post
此外,我发现您将所有内容作为单个字符串值发送。你不需要这样做。您可以发送javascript对象并使用视图模型作为参数,默认模型绑定器将能够将发布的对象映射到视图模型对象属性。