示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                using (WebhostEntities db = new WebhostEntities())
                {
                    int year = DateRange.GetCurrentAcademicYear();

                    DormSelector.DataSource     = db.Dorms.Where(d => d.AcademicYearId == year).ToList();
                    DormSelector.DataTextField  = "Name";
                    DormSelector.DataValueField = "id";
                    DormSelector.DataBind();

                    DormHeadSelector.DataSource = (from faculty in db.Faculties
                                                   orderby faculty.LastName, faculty.FirstName
                                                   select new
                    {
                        Name = faculty.FirstName + " " + faculty.LastName,
                        id = faculty.ID
                    }).ToList();
                    DormHeadSelector.DataTextField  = "Name";
                    DormHeadSelector.DataValueField = "id";
                    DormHeadSelector.DataBind();
                }
            }
        }
示例#2
0
        protected void DormSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                Dorm dorm = db.Dorms.Where(d => d.id == DormId).Single();
                DormHeadSelector.ClearSelection();
                DormHeadSelector.SelectedValue = Convert.ToString(dorm.DormHeadId);

                DormParentSelector.Clear();
                DormParentSelector.AddFaculty(dorm.DormParents.Select(f => f.ID).ToList());

                StudentSelector.Clear();
                StudentSelector.AddStudent(dorm.Students.Select(s => s.ID).ToList());
            }
        }