protected void Page_Load(object sender, EventArgs e) { int? assignmentId = Utilities.TryToParseAsInt(Request.QueryString["aid"]); lms_Entities db = new ClientDBEntities(); //get CoursesInOrder option Assignment asg = db.Assignments.Where(a => a.assignmentId == assignmentId).FirstOrDefault(); cbAvailableInOrder.Checked = asg.availCoursesInOrder; //get and sort courses List <Assignment_CoursesGet_Result> allCourses = db.Assignment_CoursesGet(assignmentId).ToList(); if (asg.availCoursesInOrder) { allCourses = allCourses.OrderBy(c => c.orderId).ToList(); } else { allCourses = allCourses.OrderBy(c => c.title).ToList(); } //bind list rptCourses.DataSource = allCourses; rptCourses.DataBind(); //show no courses available message litNoResult.Visible = rptCourses.Items.Count == 0; }
protected void Page_Load(object sender, EventArgs e) { lms_Entities db = new ClientDBEntities(); //load list of courses ddlCourses.DataSource = db.Courses.OrderBy(c => c.title).ToList(); ddlCourses.DataValueField = "courseId"; ddlCourses.DataTextField = "title"; ddlCourses.DataBind(); //load assignment settings int?assignmentId = Utilities.TryToParseAsInt(Request.QueryString["aId"]); if (assignmentId != null) { Assignment asg = db.Assignments.Where(a => a.assignmentId == assignmentId).FirstOrDefault(); cbEnabled.Checked = asg.enabled; txtTitle.Text = asg.title; txtDescription.Text = asg.description; txtDueDate.Text = asg.dueDate?.ToShortDateString(); txtDueDays.Text = asg.dueDaysAfterAssigned.ToString(); cbEmailOnAssigned.Checked = asg.sendEmailOnAssigned; cbEmailPeriodic.Checked = asg.sendEmailPeriodic; txtPeriodicDays.Text = asg.periodicDays.ToString(); cbEmailNearDueDate.Checked = asg.sendEmailNearDueDate; txtNearDueDateDays.Text = asg.nearDueDateDays.ToString(); cbEmailDueDate.Checked = asg.sendEmailOnDueDate; cbEmailOverdue.Checked = asg.sendEmailOverdue; txtOverdueDays.Text = asg.overdueDays.ToString(); //get selected course..there will always be 1 or 0 List <Assignment_CoursesGet_Result> asgCourses = db.Assignment_CoursesGet(assignmentId).Where(c => c.IsInAssignment == true).ToList(); if (asgCourses.Count > 0) { ddlCourses.SelectedValue = asgCourses[0].courseId.ToString(); } } }