protected void Page_Load(object sender, EventArgs e) { msgLabel.Text = ""; try { departmentDropDownList.DataTextField = "DepartmentCode"; departmentDropDownList.DataValueField = "departmentId"; semesterDropDownList.DataTextField = "SemesterName"; semesterDropDownList.DataValueField = "SemesterId"; dayDropDownList.DataTextField = "dayName"; dayDropDownList.DataValueField = "dayId"; buildingDropDownList.DataTextField = "buildingName"; buildingDropDownList.DataValueField = "buildingId"; courseDropDownList.DataTextField = "courseCode"; courseDropDownList.DataValueField = "courseId"; roomDropDownList.DataTextField = "roomName"; roomDropDownList.DataValueField = "roomId"; if (!IsPostBack) { List <Course> courses = new List <Course>(); List <Day> days = new List <Day>(); List <Department> departments = new List <Department>(); List <Semester> semester = new List <Semester>(); List <Building> buildings = new List <Building>(); aDepartmentManager = new DepartmentManager(); departments = aDepartmentManager.GetAllDepartments(); SemesterManager aSemesterManager = new SemesterManager(); semester = aSemesterManager.GetAllSemesters(); aScheduleManager = new ScheduleManager(); buildings = aScheduleManager.GetAllBuildings(); days = aScheduleManager.GetAllDays(); aCourseManager = new CourseManager(); courses = aCourseManager.GetAllCourses(); dayDropDownList.DataSource = days; dayDropDownList.DataBind(); departmentDropDownList.DataSource = departments; departmentDropDownList.DataBind(); semesterDropDownList.DataSource = semester; semesterDropDownList.DataBind(); buildingDropDownList.DataSource = buildings; buildingDropDownList.DataBind(); courseDropDownList.DataSource = courses; courseDropDownList.DataBind(); } } catch (Exception exception) { msgLabel.ForeColor = Color.Red; msgLabel.Text = exception.Message; } }