protected void BtnQuestionEdit_Click(object sender, EventArgs e) { try { int qid = Convert.ToInt32(Request.QueryString["qid"]); var editObj = _db.Questions.Find(qid); editObj.QuestionDescription = Request.Form["QuestionTextBox"]; editObj.SubjectId = Convert.ToInt32(this.SubjectDropDownList.Text); editObj.Ans1 = Request.Form["Ans1TextBox"]; editObj.Ans2 = Request.Form["Ans2TextBox"]; editObj.Ans3 = Request.Form["Ans3TextBox"]; editObj.Ans4 = Request.Form["Ans4TextBox"]; editObj.TrueAns = Convert.ToInt32(Request.Form["TrueAnsTextBox"]); _db.Entry(editObj).State = EntityState.Modified; _db.SaveChanges(); Response.Redirect("AdminIndex.aspx"); } catch (Exception exception) { } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["qid"] != null) { var db = new OnlineExamDbConbtext(); int qid = Convert.ToInt32(Request.QueryString["qid"]); var objDel = db.Questions.Find(qid); db.Entry(objDel).State = EntityState.Deleted; // db.SaveChanges(); var msg = "RedFromQDF"; Response.Redirect("AdminIndex.aspx?redForm=" + msg); } }
protected void Page_Load(object sender, EventArgs e) { try { LabelSubjectAddReqMsg.Text = ""; LabelSubjectAddSuccessMsg.Text = ""; SubjectAddTextBox.CssClass = "form-control"; if (Request.QueryString["sid"] != null) { var sid = Convert.ToInt32(Request.QueryString["sid"]); var objSubjectDel = _db.Subjects.Find(sid); _db.Entry(objSubjectDel).State = EntityState.Deleted; _db.SaveChanges(); Response.Redirect("AdminIndex.aspx"); } ExceptionMsgDisplayLabel.Visible = false; } catch (Exception exception) { ExceptionMsgDisplayLabel.Visible = true; ExceptionMsgDisplayLabel.Text = exception.Message; } }