public void CreateList() { string lvl = LevelChoser.GetItemText(LevelChoser.SelectedItem); if (lvl.Equals("All")) { if (courses_layout.Controls.Count > 0) { courses_layout.Controls.Clear(); } AspireDB db = new AspireDB(); List <Course> clist = db.Courses.ToList(); foreach (Course c in clist) { CoursesView cv = new CoursesView(c); courses_layout.Controls.Add(cv); } db.Database.Connection.Close(); } else { if (courses_layout.Controls.Count > 0) { courses_layout.Controls.Clear(); } AspireDB db = new AspireDB(); List <Course> clist = db.Courses.Where(x => x.Level == lvl).ToList(); foreach (Course c in clist) { CoursesView cv = new CoursesView(c); courses_layout.Controls.Add(cv); } db.Database.Connection.Close(); } }
public void CreateList() { if(courses_layout.Controls.Count>0) { courses_layout.Controls.Clear(); } AspireDB db = new AspireDB(); List<Course> clist = db.Courses.ToList(); foreach (Course c in clist) { CoursesView cv = new CoursesView(c); courses_layout.Controls.Add(cv); } db.Database.Connection.Close(); }