private void btnModify_Click(object sender, EventArgs e) { if (lblSelected.Text != "") { Classes newClass = new Classes(); newClass.ClassID = Convert.ToInt32(lblSelected.Text); newClass.ClassTitle = dataGridView1.CurrentRow.Cells[1].Value.ToString(); newClass.ClassTrack = dataGridView1.CurrentRow.Cells[2].Value.ToString(); ClassesDB.TempSave(newClass); ClassEdit newForm = new ClassEdit(); newForm.Show(); } else { MessageBox.Show("Please select a class to modify"); } }