public AllClassesForm(FacultyUserModel gotFaculty) { InitializeComponent(); faculty = gotFaculty; labelWelcome.Text = faculty.FullName; try { ClassController ccontroller = new ClassController(); List <ClassModel> allClassesList = ccontroller.GetByFacultyId(faculty.Id); //Console.WriteLine(allClassesList.Count + " improper classes"); List <ProperClassModel> properClassList = new List <ProperClassModel>(); foreach (ClassModel model in allClassesList) { ProperClassModel properModel = new ProperClassModel(); properModel.ClassDate = model.ClassDate; properModel.ClassType = model.ClassType; properModel.EndTimeId = model.EndTimeId; properModel.Id = model.Id; properModel.RoomNo = model.RoomNo; properModel.SectionId = model.SectionId; properModel.StartTimeId = model.StartTimeId; //Console.WriteLine("improper date: " + model.ClassDate + " | proper date: " + properModel.ClassDate); SectionController scontroller = new SectionController(); properModel.SectionName = scontroller.Get(model.SectionId).SectionName; ClassTimeController ctcontroller = new ClassTimeController(); properModel.Time = ctcontroller.Get(model.StartTimeId).ClassTimeText + " - " + ctcontroller.Get(model.EndTimeId).ClassTimeText; properClassList.Add(properModel); } MySortableBindingList <ProperClassModel> bindingClassesList = new MySortableBindingList <ProperClassModel>(properClassList); //Console.WriteLine(bindingClassesList.Count + " classes found"); dataGridViewClassList.AutoGenerateColumns = false; dataGridViewClassList.DataSource = bindingClassesList; dataGridViewSerial.AutoGenerateColumns = false; dataGridViewSerial.DataSource = bindingClassesList; } catch (Exception ex) { MessageBox.Show(ex.Message); } dataGridViewSerial.DataBindingComplete += (o, e) => { foreach (DataGridViewRow row in dataGridViewSerial.Rows) { row.Cells["sln"].Value = (row.Index + 1).ToString(); } }; }