private void DisplayMarks_Click(object sender, EventArgs e) { try { int groupSelectedIndex = GroupNameDisplaycomboBox.SelectedIndex; int GroupId = groupsList[groupSelectedIndex].GroupId; int subjectSelectedIndex = SubjectNameDisplaycomboBox.SelectedIndex; int SubjectId = subjectsList[subjectSelectedIndex].SubjectId; DataTable dta = repository.DisplayStudentsMarksForTeacher(SubjectId, GroupId); dataGridView1.DataSource = dta; } catch (Exception exc) { MessageBox.Show(exc.ToString()); } }