// Update private void Update_Click(object sender, EventArgs e) { if (comboBox1.Text == "") { MessageBox.Show("Enter your StudentId"); } else { try { using (Online_Exame ent = new Online_Exame()) { var ins = ent.Instractors.Find(ins_id); int Ins_dept = (int)ins.Dept_id; Student student = ent.Students.Find(int.Parse(comboBox1.Text)); ent.UpdateStudent(student.St_id, txtFname.Text, txtLname.Text, txtaddress.Text, int.Parse(txtage.Text), txtEmail.Text, Ins_dept); comboBox1.Text = txtFname.Text = txtLname.Text = txtEmail.Text = txtage.Text = txtaddress.Text = string.Empty; MessageBox.Show("Updated successfully"); loadDataGrid(); } } catch (NullReferenceException) { MessageBox.Show("Incorrect ID"); } catch (FormatException) { MessageBox.Show("Invaild Format"); } } }