private void LoadStudents() { // First time in, load the dropdown with students using (Lab13Entities myEntities = new Lab13Entities()) { // Set the studentSelect object with the results of the LINQ query var studentSelect = from student in myEntities.Students orderby student.LastName select new { ID = student.StudentID, Name = student.LastName + ", " + student.FirstName }; // Load the dropdown with the query results. ddlStudent.DataSource = studentSelect.ToList(); // Specify which data columns show up in the dropdown ddlStudent.DataValueField = "ID"; ddlStudent.DataTextField = "Name"; ddlStudent.DataBind(); // Preselect the first entry in the dropdown. ddlStudent.SelectedIndex = 0; // Load the listview with the first student in the dropdown. LoadClassMeetings(int.Parse(ddlStudent.SelectedValue), false); } }
/// <summary> /// Load the ListView with the student passed /// </summary> /// <param name="studentID"></param> private void LoadClassMeetings(int studentID, bool onlyUnexcused) { using (Lab13Entities myEntities = new Lab13Entities()) { // Get the data for the listview, filtering on the studentID and the type of attendance // The query need to join ClassMeetings to Calendars and ClassMeetings to Attendences var classMeeting = from m in myEntities.ClassMeetings join c in myEntities.Calendars on m.CalendarID equals c.CalendarID join a in myEntities.Attendances on m.AttendanceID equals a.AttendanceID where m.StudentID == studentID orderby c.Date select new { Date = c.Date, Attendance = a.AttendanceID }; // Load the listview with the data. grvAttendence.DataSource = classMeeting.ToList(); grvAttendence.DataBind(); // Set the record count into the label lblRecordsFound.Text = string.Format("Records Found: {0}", classMeeting.Count()); } }
private void LoadStudents() { using (Lab13Entities myEntities = new Lab13Entities()) { // Get the data for the listview, filtering on the studentID and the type of attendance var students = from student in myEntities.Students orderby student.LastName, student.FirstName select student; // Load the listview with the data. grvStudents.DataSource = students.ToList(); grvStudents.DataBind(); // Set the record count into the label lblRecordsFound.Text = string.Format("Records Found: {0}", students.Count()); } }
private void LoadSections() { using (Lab13Entities myEntities = new Lab13Entities()) { // Get the data for the listview, filtering on the studentID and the type of attendance var sections = from section in myEntities.Sections select new { Section = section.Name, Hours = section.CreditHours }; // Load the listview with the data. grvSections.DataSource = sections.ToList(); grvSections.DataBind(); // Set the record count into the label lblRecordsFound.Text = string.Format("Records Found: {0}", sections.Count()); } }
private void LoadSections() { using (Lab13Entities myEntities = new Lab13Entities()) { // Get the data for the gridview var sections = from s in myEntities.Sections join r in myEntities.Registrations on s.SectionID equals r.SectionID group s by s.Name into grouped select new { SectionName = grouped.Key, StudentCount = grouped.Count() }; // Load the listview with the data. grvSections.DataSource = sections.ToList(); grvSections.DataBind(); // Set the record count into the label lblRecordsFound.Text = string.Format("Records Found: {0}", sections.Count()); } }