passing data from jqGrid to webmethod(将数据从 jqGrid 传递到 webmethod)
本文介绍了将数据从 jqGrid 传递到 webmethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的 jqGrid 调用 web 方法
This is my jqGrid calling web method
$(document).ready(function () {
jQuery("#prodgrid").jqGrid({
url: 'product_brow.aspx/ProdGrid',
postData: {
ddlproductstatus: function() {
return $("#<%=ddlProductStatus.ClientID%>").val();
},
ddlproducttype: function() {
return $("#<%=ddlProductType.ClientID%>").val();
},
txtkeywordsearch: function() {
return $("#<%=txtKeywordSearch.ClientID%>").val();
},
hdnMerchantId: function() {
return $("#<%=hdnmerchantId.ClientID%>").val();
}
},
mtype: 'POST',
serializeEditData: function (postData) {
return JSON.stringify(postData);
} ,
colNames: ['Code', 'Title', 'Price', 'Product Group', 'Edit', 'Status'],
colModel: [
{ name: 'Code', index: 'Code', width: 15, align: 'center' },
{ name: 'Title', index: 'Title', width: 40, align: 'center' },
{ name: 'Price', index: 'Price', width: 55 },
{ name: 'Product Group', index: 'Product Group', width: 55 },
{ name: 'Edit', index: 'Edit', width: 40 },
{ name: 'Status', index: 'Status', width: 40}],
pager: '#prod_pager',
rowList: [10, 20, 30],
sortname: 'Code',
sortorder: 'desc',
rowNum: 10,
loadtext: "Loading....",
shrinkToFit: true,
multiselect: true,
emptyrecords: "No records to view",
width: x - 40,
height: 230,
rownumbers: true,
subGrid: true,
caption: 'Products'
// editurl: 'Departments.aspx'
});
jQuery("#prodgrid").jqGrid('navGrid', '#prod_pager',
{ edit: false, add: false, del: true, excel: true, search: false });
});
如您所见,我正在尝试使用这样的参数将数据从这里传递到 web 方法
as you can see im trying to pass data from here to web method with parameters like this
[WebMethod]
public static string ProdDetails(string ddlproductstatus,
string ddlproducttype,
string txtkeywordsearch,
string hdnMerchantId)
{
StringBuilder sbReturnJson = new StringBuilder();
string strReturnJson = string.Empty;
StringBuilder sbCell = new StringBuilder();
try
{
string sort = HttpContext.Current.Request.Form["sidx"].ToString();
string strSortDerection = HttpContext.Current.Request.Form["sord"].ToString();
int iPage = Convert.ToInt32(HttpContext.Current.Request.Form["page"]);//get the requested page
string strLimit = HttpContext.Current.Request.Form["rows"].ToString(); // get how many rows we want to have into the grid
string strStart = Convert.ToString(int.Parse(strLimit) * (iPage - 1));
string strEnd = Convert.ToString(int.Parse(strStart) + int.Parse(strLimit));
string pageNo = string.Empty;
ProductDal oProductDal = new ProductDal();
// bind data to gridview
System.Data.DataTable oDataTable;
if (txtkeywordsearch.Trim().Length == 0)
{
oDataTable = oProductDal.GetAllProductDtToDisplayTest(Convert.ToInt32(hdnMerchantId), ddlproducttype,
ddlproductstatus, iPage, Convert.ToInt32(strLimit));
}
else
{
oDataTable = oProductDal.GetAllProductDtToDisplayBySearchStringTest(Convert.ToInt32(hdnMerchantId), ddlproducttype,
ddlproductstatus, txtkeywordsearch.Trim(), iPage, Convert.ToInt32(strLimit));
}
// keep values in session to use in product detail page to retrieve records.
//Session["ProductType"] = ddlproducttype;
// Session["ProductStatus"] = ddlproductstatus;
if (txtkeywordsearch.Trim().Length != 0)
{
// Session["SearchKeyword"] = txtkeywordsearch;
}
// hlnkExportToExcel.Visible = false;
// calculate the total number of records.
int totalRows = 0;
if (txtkeywordsearch.Trim().Length == 0)
{
totalRows = oProductDal.CountAllProductDtToDisplay(Convert.ToInt32(hdnMerchantId), ddlproducttype,
ddlproductstatus);
}
else
{
totalRows = oProductDal.CountAllProductDtToDisplayBySearchString(Convert.ToInt32(hdnMerchantId), ddlproducttype,
ddlproductstatus, txtkeywordsearch.Trim());
}
//if (!IsPostBack)
//{
// gvProductBrow.PageIndex = _currentPageNumber;
/
沃梦达教程
本文标题为:将数据从 jqGrid 传递到 webmethod
基础教程推荐
猜你喜欢
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01