public DataTable getAllCoursebySid(int sid) { CourseService couService = new CourseService(); DataTable dt = couService.getCourseBySid(sid,1); dt.Columns.Add("trans_week", typeof(string)); foreach (DataRow dr in dt.Rows) { if (dr["week"].ToString() == "1") { dr["trans_week"] = "1-16"; } else if (dr["week"].ToString() == "2") { dr["trans_week"] = "1-8"; } else { dr["trans_week"] = "9-16"; } } TeacherService teachService = new TeacherService(); dt.Columns.Add("tname", typeof(string)); foreach (DataRow dr in dt.Rows) { dr["tname"] = teachService.getTnameByTid(int.Parse(dr["tid"].ToString())); } return dt; }