private void GetDataForCombobox(HttpContext context) { var ds = new DataSet(); var couBll = new BLL.Course(); ds = couBll.GetAllList(); // [{"SUBITEM_VALUE":"1","SUBITEM_NAME":"男"},{"SUBITEM_VALUE":"2","SUBITEM_NAME":"女"}] if (ds != null && ds.Tables.Count > 0) { var str = new StringBuilder("["); foreach (DataRow row in ds.Tables[0].Rows) { str.Append("{\"CourseId\": \"" + row["CourseId"] + "\","); str.Append("\"CourseName\": \"" + row["CourseName"] + "\"},"); } str.Remove(str.Length - 1, 1); str.Append("]"); context.Response.Write(str.ToString()); } // var str = JsonConvert.SerializeObject(new { total = ds.Tables[0].Rows.Count, rows = ds.Tables[0] }); }
/// <summary> /// 提取意见列表 /// </summary> /// <param name="context"></param> private void GetSuggestions(HttpContext context) { var ds = new DataSet(); var courBll = new BLL.Course(); ds = courBll.GetAllList(); var courseId = context.Request["coId"]; if (!string.IsNullOrEmpty(courseId)) { var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); var startIndex = (page - 1) * rows + 1; var endIndex = startIndex + rows - 1; var questionbll = new BLL.Questionnaire(); var num = questionbll.GetSuggestion(courseId) == null ? 0 : questionbll.GetSuggestion(courseId).Tables[0].Rows.Count; ds = questionbll.GetSuggestionByPage(courseId, "", startIndex, endIndex); var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] }); context.Response.Write(str); } }