Model赋值返回json
2016-12-05 15:09
351 查看
DataTable resultList = bll.GetResultListByCondition(bureauCode, deptCode, fileTitle);
IList<GanBuTianChengTongZhiGuanLiResultViewModel> list = new List<GanBuTianChengTongZhiGuanLiResultViewModel>();
//遍历行对象
foreach (DataRow drEntry in resultList.Rows)
{
GanBuTianChengTongZhiGuanLiResultViewModel resultModel = new GanBuTianChengTongZhiGuanLiResultViewModel();
PropertyInfo[] propertys = resultModel.GetType().GetProperties();
foreach (PropertyInfo item in propertys)
{
item.SetValue(resultModel, drEntry[item.Name].ToString(), null);
}
list.Add(resultModel);
}
jsonResult = new JavaScriptSerializer().Serialize(list);
return jsonResult;
IList<GanBuTianChengTongZhiGuanLiResultViewModel> list = new List<GanBuTianChengTongZhiGuanLiResultViewModel>();
//遍历行对象
foreach (DataRow drEntry in resultList.Rows)
{
GanBuTianChengTongZhiGuanLiResultViewModel resultModel = new GanBuTianChengTongZhiGuanLiResultViewModel();
PropertyInfo[] propertys = resultModel.GetType().GetProperties();
foreach (PropertyInfo item in propertys)
{
item.SetValue(resultModel, drEntry[item.Name].ToString(), null);
}
list.Add(resultModel);
}
jsonResult = new JavaScriptSerializer().Serialize(list);
return jsonResult;
相关文章推荐
- Jquery 局部刷新及 表单取值赋值 处理返回json数据 一些基本操作
- ajax接收后台传来的JSON类型数据,可通过循环遍历为input赋值(input的ID需要和返回来的数据名相同)
- js 遍历json对象并为select赋值 (ajax返回的json对象)
- php ajax从后台返回json数据,并把数据赋值给自动生成HTML标签
- 2016-12-03(两种处理JSON返回页面的方式、分页,ModelAndView和Model的区别,<C:forEach>注意)
- 学习网络请求返回json对应的model
- Jquery 局部刷新及 表单取值赋值 处理返回json数据 一些基本操作
- C# Webservice 返回Json序列 字符串 前台赋值给json数组
- struts2+ajax 解析返回的json数据 并赋值给select标签
- Spring控制器响应(action)请求的几种处理方式,如返回JSON,MODEL MODELVIEW,STRING
- FLEX4.7 与Java后台交互返回json格式的数组 并赋值给前台datagrid
- Jquery 局部刷新及 表单取值赋值 处理返回json数据
- Jquery 表单取值赋值 处理返回json数据
- Jquery 局部刷新及 表单取值赋值 处理返回json数据 一些基本操作
- jquery 中$.post获取MVC Controller中JsonResult返回包含LIst<Model>类型的子List<Model>的高级使用方法
- Jquery 表单取值赋值 处理返回json数据
- [置顶] php jQuery把后台返回的json数据赋值给页面标签
- jquery 中$.post获取MVC Controller中JsonResult返回包含LIst<Model>类型的子List<Model>的高级使用方法
- 使用Json字符串对model对象赋值
- Struts返回Json 格式result时action中方法调用两次