int index=1;
DataTable dt = BLL.AttendanceInfo.GetAttendanceInfo(index);
List<object> list = new List<object>();
foreach(DataRow dr in dt.Rows)
{
Model.UserInfo u = new Model.UserInfo();
u.UserID = dr["UserID"].ToString();
u.UserName = dr["UserName"].ToString();
Model.DepartmentList d = new Model.DepartmentList();
d.DeptName = dr["DeptName"].ToString();
list.Add(new { UserInfo = u, DepartmentList = d });
}
JavaScriptSerializer js = new JavaScriptSerializer();
string json = js.Serialize(js);
context.Response.Write(json);
具体是什么问题呢?
alert出来的是这东西,处理程序也没出错。
@灬丶:
int index=1;
DataTable dt = BLL.AttendanceInfo.GetAttendanceInfo(index);
List<object> list = new List<object>();
foreach(DataRow dr in dt.Rows)
{
Model.UserInfo u = new Model.UserInfo();
u.UserID = dr["UserID"].ToString();
u.UserName = dr["UserName"].ToString();
Model.DepartmentList d = new Model.DepartmentList();
d.DeptName = dr["DeptName"].ToString();
list.Add(new { UserInfo = u, DepartmentList = d });
}
JavaScriptSerializer js = new JavaScriptSerializer();
string json = js.Serialize(list);
context.Response.Write(json);
什么问题?你那list,干嘛非要弄个Object?直接强类型不行?
string json = js.Serialize(js);
序列化错对象了
这个可以配置的,找一下。但是,已经提示你,你的数据太多已经超长了。