我想显示这种 总页数:
当前页:
我该怎样得到总页数呢?代码如下,请高手帮帮忙,多谢 OleDbDataAdapter objCommand=new OleDbDataAdapter("Select * From grade",objConn);
DataSet ds=new DataSet();
objCommand.Fill(ds); PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 2; int CurPage;
if (Request.QueryString["Page"] != null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1; objPds.CurrentPageIndex = CurPage-1; //当前页
lblCurrentPage.Text = "第 " + CurPage.ToString() + " 页";
if (!objPds.IsFirstPage)
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage-1); if (!objPds.IsLastPage)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page=" + Convert.ToString(CurPage+1); Repeater1.DataSource=objPds;
Repeater1.DataBind();
当前页:
我该怎样得到总页数呢?代码如下,请高手帮帮忙,多谢 OleDbDataAdapter objCommand=new OleDbDataAdapter("Select * From grade",objConn);
DataSet ds=new DataSet();
objCommand.Fill(ds); PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 2; int CurPage;
if (Request.QueryString["Page"] != null)
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1; objPds.CurrentPageIndex = CurPage-1; //当前页
lblCurrentPage.Text = "第 " + CurPage.ToString() + " 页";
if (!objPds.IsFirstPage)
lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage-1); if (!objPds.IsLastPage)
lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+ "?Page=" + Convert.ToString(CurPage+1); Repeater1.DataSource=objPds;
Repeater1.DataBind();
如果要用rs.PageCount
下面的游标和锁定方式不是任选的
rs.Open StrSQL,conn,adOpenStatic,adLockReadOnly,adCmdText
public int CurrentPage
{
get
{
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0;
else
return (int) o;
} set
{
this.ViewState["_CurrentPage"] = value;
}
}