public void GetHistory() { string userId = Session["sn"].ToString(); string sql = "select id, examId, score, datetime from exam_record where userId = @userId"; Mysqldb mysqldb = new Mysqldb(); MySqlConnection connection = mysqldb.getConnection(); MySqlCommand cmd = mysqldb.getCommand(connection); cmd.CommandText = sql; cmd.Parameters.AddWithValue("@userId", userId); MySqlDataAdapter da = new MySqlDataAdapter(); connection.Open(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds, "history"); GridView_Exam_History.DataSource = ds; GridView_Exam_History.DataBind(); connection.Close(); }
protected void GridView_Exam_History_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView_Exam_History.PageIndex = e.NewPageIndex; GridView_Exam_History.DataBind(); }