protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (Session["setq"] != null) { Label lblID = GridView1.Rows[e.RowIndex].FindControl("lblID") as Label; TextBox txtLastName = GridView1.Rows[e.RowIndex].FindControl("txtLastName") as TextBox; Label lblI1 = GridView1.Rows[e.RowIndex].FindControl("lblI1") as Label; Label lblI2 = GridView1.Rows[e.RowIndex].FindControl("lblI2") as Label; Label lblI3 = GridView1.Rows[e.RowIndex].FindControl("lblI3") as Label; CourseHandler courseHandler = new CourseHandler(); Student user = new Student(); user.studentName = ""; user.idNumber = ""; user.email = (string)Session["user"]; user.password = (string)Session["pass"]; CourseDBAccess courseDB = new CourseDBAccess(); courseDB.GetStudentDetails(user); QuizAns quiz = new QuizAns(); quiz.courseID = Convert.ToInt32(Request.QueryString["id"]); quiz.studentID = user.studentID; quiz.questionID = Convert.ToInt32(lblID.Text.Trim()); quiz.Ans = txtLastName.Text; //Let us now update the database courseHandler.UpdateQuizAns(quiz); //end the editing and bind with updated records. GridView1.EditIndex = -1; BindData(); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Login First');", true); } }
public bool UpdateQuizAns(QuizAns quiz) { return(courseDB.UpdateQuizAns(quiz)); }