protected void btnDeleteSection_Click(object sender, EventArgs e) { Sections sec = new Sections(); Question ques=new Question (); Assessment ass = new Assessment(); AnswerDetail ansDetail = new AnswerDetail(); CVTCMenu menu=new CVTCMenu (); QuestionResponse qr=new QuestionResponse (); int sectOID = Convert.ToInt32(Request.QueryString["soid"].ToString()); int AssOID = sec.GetAssessmentOIDBySectionOID(sectOID); if (ass.GetAssessmentStatusByOID(Convert.ToInt32(AssOID)) == 1) { LabelMessage.Text = "This group can not be deleted.It has been Locked"; return; } else { string menuURL = "pg/assessment/section.aspx?soid=" + sectOID + ""; //Delete from AnswerDetails and Question Table by SectionOID bool DeleteFromAnswerDetail=ansDetail.DeleteAnswerDetailBySectionOID(sectOID); Collection<Question> qList = new Collection<Question>(); qList = ques.GetQuestionOIDBySectionOID(sectOID); foreach (Question q in qList ) { qr.DeleteQuestionBySectionOID(q.QuestionOID); } bool DeleteFromQuestion = ques.DeleteQuestionBySectionOID(sectOID); bool DeleteFromMenu = menu.DeleteMenuByMenuURL(menuURL); bool DeleteFromSection = sec.DeleteSectionBySectionOID(sectOID); if (DeleteFromSection && DeleteFromMenu) { InitializeQuestion(sectOID); LabelMessage.Text = "This question group has been deleted successfully"; } else { LabelMessage.Text = "This question group can not be deleted.Please try again.."; } ButtonRefresh_Click(null, null); } }