标签:
DataTable转换为JsonResult
时间 2014-02-07 20:02:00 博客园-所有随笔区原文 http://www.cnblogs.com/DaneJiang/p/3539866.html
1、从数据库获取DataTable类型:
DataTable dt = DBConn.GetPageList(pageIndex, pageSize, "select * from erp_process" + pageSort, ref rowCount);
2、DataTable转换为var类型:
var query = from p in dt.AsEnumerable()
select new
{
ID = int.Parse(p["ID"].ToString()),
ProcessCode = p["ProcessCode"].ToString(),
ProcessName = p["ProcessName"].ToString(),
ProcessType = p["ProcessType"].ToString(),
ProcessMan = p["ProcessMan"].ToString(),
ProcessTypeName = TypeMapping(p["ProcessType"].ToString()),
ProcessManName = ManMapping(p["ProcessMan"].ToString())
};
3、返回JsonResult类型:
Json(new { rows = query, total = rowCount }, JsonRequestBehavior.AllowGet);
DataTable转换为JsonResult - DaneJiang
标签:
原文地址:http://www.cnblogs.com/piguo/p/4760627.html