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()); 
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 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/archive/2011/10/18/2216513.html

你可能感兴趣的:(Controller层返回Json数据)