protected void Page_Load(object sender, EventArgs e) { AuthHelper.LoginCheck(Session, Request, Response, Server); if (!IsPostBack) { var all = new ClassServiceImpl().GetAll(); DropDownList1.DataSource = all; //绑定班级 DropDownList1.DataTextField = "Name"; DropDownList1.DataValueField = "ClassId"; DropDownList1.DataBind(); ArrayList schoolYear = new ArrayList(); //绑定学年 for (int i = DateTime.Now.Year; i >= DateTime.Now.Year - 6; i--) { schoolYear.Add((i) + "-" + (i + 1)); } SchoolYear.DataSource = schoolYear; SchoolYear.DataBind(); ArrayList semester = new ArrayList(new int[] { 1, 2, 3 }); Semester.DataSource = semester; Semester.DataBind(); if (Request.QueryString["id"] != null) { int CourseId = int.Parse(Request.QueryString["id"]); CourseServiceImpl courseServiceImpl = new CourseServiceImpl(); Course course = (Course)courseServiceImpl.GetById(CourseId); //绑定数据 CourseName.Value = course.Name; DropDownList1.Text = string.Concat(course.ClassId); SchoolYear.Text = course.SchoolYear; Semester.Text = course.Semester; ShortCourseIntro.Value = course.ShortIntroduction; } } }
protected void Page_Load(object sender, EventArgs e) { AuthHelper.LoginCheck(Session, Request, Response, Server); AuthHelper.TeacherOnlyPage(Session, Request, Response, Server); var all = new ClassServiceImpl().GetAll(); DropDownList1.DataSource = all; //绑定班级 DropDownList1.DataTextField = "Name"; DropDownList1.DataValueField = "ClassId"; DropDownList1.DataBind(); ArrayList schoolYear = new ArrayList(); //绑定学年 for (int i = DateTime.Now.Year; i >= DateTime.Now.Year - 6; i--) { schoolYear.Add((i) + "-" + (i + 1)); } SchoolYear.DataSource = schoolYear; SchoolYear.DataBind(); ArrayList semester = new ArrayList(new int[] { 1, 2, 3 }); Semester.DataSource = semester; Semester.DataBind(); }