首页 > Web开发 > 详细

DataTable转换为JsonResult

时间:2014-02-08 00:09:31      阅读:983      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/DaneJiang/p/3539866.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!