public void ResetBar() { FinalDDL.ClearSelection(); FinalDDL.SelectedValue = Convert.ToString(AFDefault); ExamDDL.ClearSelection(); ExamDDL.SelectedValue = Convert.ToString(AFDefault); TrimesterDDL.ClearSelection(); TrimesterDDL.SelectedValue = Convert.ToString(AFDefault); EffortDDL.ClearSelection(); EffortDDL.SelectedValue = Convert.ToString(EffortDefault); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int year = DateRange.GetCurrentAcademicYear(); using (WebhostEntities db = new WebhostEntities()) { GradeTable stdaf = db.GradeTables.Where(gt => gt.AcademicYearID == year && gt.Name.Equals("Standard A-F Scale")).Single(); AFDefault = stdaf.GradeTableEntries.Where(gte => gte.Value > 500).Single().id; FinalDDL.DataSource = stdaf.GradeTableEntries.ToList(); FinalDDL.DataTextField = "Name"; FinalDDL.DataValueField = "id"; FinalDDL.DataBind(); FinalDDL.ClearSelection(); FinalDDL.SelectedValue = Convert.ToString(AFDefault); ExamDDL.DataSource = stdaf.GradeTableEntries.ToList(); ExamDDL.DataTextField = "Name"; ExamDDL.DataValueField = "id"; ExamDDL.DataBind(); ExamDDL.ClearSelection(); ExamDDL.SelectedValue = Convert.ToString(AFDefault); TrimesterDDL.DataSource = stdaf.GradeTableEntries.ToList(); TrimesterDDL.DataTextField = "Name"; TrimesterDDL.DataValueField = "id"; TrimesterDDL.DataBind(); TrimesterDDL.ClearSelection(); TrimesterDDL.SelectedValue = Convert.ToString(AFDefault); GradeTable effort = db.GradeTables.Where(gt => gt.AcademicYearID == year && gt.Name.Equals("Effort Grades")).Single(); EffortDefault = effort.GradeTableEntries.FirstOrDefault().id; EffortDDL.DataSource = effort.GradeTableEntries.ToList(); EffortDDL.DataTextField = "Name"; EffortDDL.DataValueField = "id"; EffortDDL.DataBind(); EffortDDL.ClearSelection(); EffortDDL.SelectedValue = Convert.ToString(EffortDefault); } } }