private void GetDataTable() { string queryDepartment = Server.UrlDecode(Request.QueryString["queryDepartment"]).ToString(); //获取系部 string queryWeek = Request.QueryString["queryWeek"].ToString(); //获取周次 DataTable dt = AddSQLStringToDAL.GetDataTableBysql("TabStudentAttendance", "StudentDepartment", queryDepartment, "CurrentWeek", queryWeek); //获取缺勤学生信息 dt.Columns.Add(new DataColumn("SumAttendance", typeof(int))); //添加一行 for (int i = 0; i < dt.Rows.Count; i++) //填充dt { int zz = dt.Rows[i]["Course"].ToString().Length; dt.Rows[i]["Course"] = dt.Rows[i]["Course"].ToString().Substring(8, zz - 11); int zzCount = AddSQLStringToDAL.GetRecordCount("TabStudentAttendance", "StudentID", dt.Rows[i]["StudentID"].ToString()); dt.Rows[i]["SumAttendance"] = zzCount; } gvStudentAttendance.DataSource = dt; gvStudentAttendance.DataBind(); }