Controller层返回Json数据

1.public JsonResult JudgeHisList(JqGridParameter jqGridParameter, string hid) 

try 

iPAL.Models.Pub.iPAL_ManagerDataContext Qualitydb = new iPAL_ManagerDataContext(); 
var list = from a in Qualitydb.MANAGER_QUALITY_HIS_COMMENT join b in Qualitydb.MANAGER_CFG_QUALITY_HIS on a.hid equals b.Id where a.hid == Convert.ToInt32(hid) orderby a.id descending select new { remark = a.remark, userid = a.userid, addtime = a.addtime, state = b.State }; 
var resultList = list.ToList().Select(item => new 

userid=item.userid, 
remark=item.remark, 
state=item.state=="yes" ? "通过评审" : "未通过评审", 
addtime=item.addtime 
}); 

if (list.Count() < 1) 

return Json(ConvUtils.CreateNullJsonString(), JsonRequestBehavior.AllowGet); 

var jsonData = JqGridHelper.ToJson(jqGridParameter, resultList.ToList<object>()); 
return Json(jsonData, JsonRequestBehavior.AllowGet); 

catch (System.Exception ex) 

return Json(ex.Message, JsonRequestBehavior.AllowGet); 

}


2(easyui).public JsonResult ShowSheetData(string args,string rows,string page) 

int pageSize = 30, pageIndex = 1; 
CommonMethod.toInt(rows, ref pageSize); 
CommonMethod.toInt(page, ref pageIndex); 
int total = 0; 
try 

List<BIGT_ROW_DATA> lst = btModuel.GetBigTRow(args, pageSize, pageIndex - 1, ref total); 
var jsonData = new 

total = total, 
rows = lst.ToArray() 
}; 
return Json(jsonData, JsonRequestBehavior.AllowGet); 

catch 

return Json("{}", JsonRequestBehavior.AllowGet); 

}

原文地址:https://www.cnblogs.com/cw_volcano/p/2216513.html