private void LoadTable() { dataGridView1.DataSource = null; dataGridView1.Columns.Clear(); dataGridView1.Columns.Add("RollStudentColumn", "Roll"); dataGridView1.Columns["RollStudentColumn"].Width = 90; dataGridView1.Columns["RollStudentColumn"].DataPropertyName = "Roll"; dataGridView1.Columns["RollStudentColumn"].ReadOnly = true; dataGridView1.Columns.Add("NameStudentColum", "Name"); dataGridView1.Columns["NameStudentColum"].Width = 150; dataGridView1.Columns["NameStudentColum"].DataPropertyName = "Name"; dataGridView1.Columns["NameStudentColum"].ReadOnly = true; foreach (GrandItem grandItem in grandItems) { dataGridView1.Columns.Add(grandItem.RollType, grandItem.Name + " (" + grandItem.Weight + ")"); dataGridView1.Columns[grandItem.RollType].Width = 150; dataGridView1.Columns[grandItem.RollType].DataPropertyName = grandItem.RollType; } string rollSubject = SubjectComboBox.SelectedValue.ToString(); string rollClass = ClassComboBox.SelectedValue.ToString().Trim(); List <Student> students = ManagementController.GetStudent(rollClass); dataGridView1.DataSource = students; foreach (DataGridViewRow dataGridViewRow in dataGridView1.Rows) { string rollStudent = dataGridViewRow.Cells["RollStudentColumn"].Value.ToString(); foreach (GrandItem granditem in grandItems) { Double?score = ManagementController.GetScore(rollStudent, rollSubject, granditem.RollType); dataGridViewRow.Cells[granditem.RollType].Value = score != null?Math.Round((double)score, 1) : score; } } SetVisualColunm(); buttonSave.Enabled = false; }