private void deleteQuestion() { int questId = 0; if (comboBox2.SelectedItem != null) { questId = int.Parse(comboBox2.Text.ToString().Split(',')[0]); } else { MessageBox.Show("Please select course id", "Waring"); return; } Online_Exame ent = new Online_Exame(); var ques = (from q in ent.Questions where q.Quest_id == questId select q).First(); int courseId = (int)ques.Crs_id; try { ent.deleteQuestion(questId); } catch (Exception) { } LoadCourses(); loadQuestions(courseId); textBox1.Text = textBox2.Text = string.Empty; numericUpDown1.Value = 1; comboBox3.Text = string.Empty; ans1.Text = ans2.Text = ans3.Text = ans4.Text = string.Empty; }