码迷,mamicode.com
首页 > Web开发 > 详细

DataTable转换为JsonResult - DaneJiang

时间:2015-08-26 17:19:06      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!