麻烦大家帮忙看看,下面分页为什么不支持查询分页,代码如下        OleDbConnection conn = new OleDbConnection();
        conn.ConnectionString = "Provider = Microsoft.Jet.OleDb.4.0;" + "Data Source =" + Server.MapPath("AppData/11.mdb");        if (sType == "1")
        {
           
            string strSel = "select * from news where ([title] like '%" + word + "%')";            OleDbCommand selcom = new OleDbCommand(strSel, conn);
            OleDbDataAdapter da = new OleDbDataAdapter();
            conn.Open();
          
            da.SelectCommand = selcom;
            DataSet ds = new DataSet();
            da.Fill(ds, "news");
            DataTable dt = ds.Tables["news"];
          
            conn.Close();
            Repeater1.DataSource = dt;
            Repeater1.DataBind();
            int CurPage;
            if (Request.QueryString["Page"] != null)
                CurPage = Convert.ToInt32(Request.QueryString["Page"]);
            else
                CurPage = 1;
            PagedDataSource ps = new PagedDataSource();
            ps.DataSource = ds.Tables[0].DefaultView;
            ps.AllowPaging = true;
            ps.PageSize = 10;//每页数据的数量
            this.onepage.Text = ps.PageSize.ToString();
            this.allmsg.Text = ps.DataSourceCount.ToString();
            ps.CurrentPageIndex = CurPage - 1;
            this.allpage.Text = ps.PageCount.ToString();
            this.allpage1.Text = ps.PageCount.ToString();
            this.nowpage.Text = CurPage.ToString();
            this.Repeater1.DataSource = ps;
            this.Repeater1.DataBind();
            Firstpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1";
            Lastpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + ps.PageCount.ToString();            if (!ps.IsFirstPage)
                prepage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
            if (!ps.IsLastPage)
                nextpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);      
        }
现在情况是查询后数据能显示,也能算出总共多少条记录,及多少页,但是按"上一页,下一页,末页"就不行了
注:这个分页代码如果不是搜索可以正常运行的。

解决方案 »

  1.   

    是怎么样的不行?报错了还是点翻页按钮没反应??
    也没搞明白你说的什么意思。。你说的搜索是在带有QueryString的页面"?Page=.." 直接点搜索按钮吗?搜索后应该ps.pageindex=0吧
      

  2.   

    是点击翻页,数据就没有了如不是搜索,如
    string strSel = "select * from news";
    这样分页功能正常。
      

  3.   

    是点击翻页,数据就没有了 如不是搜索,如 
    string strSel = "select * from news"; 
    这样分页功能正常。 
      

  4.   

    是点击翻页,数据就没有了 如不是搜索,如 
    string strSel = "select * from news"; 
    这样分页功能正常。