我用Repeater来显示单条数据的内容...
加了上一页和下一页的导航链接..点击的话.就可以找出一样分类的下一条记录..
想不明白那种算法..
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
PagedDataSource objPds = new PagedDataSource(); //创建分页记录集
objPds.DataSource = this.bindDS().Tables[0].DefaultView; //绑定DataSet
objPds.AllowPaging = true; //开启分页
objPds.PageSize = 5; //每页显示记录数
int RowCount; //获取有多少行
try
{
RowCount = this.bindDS().Tables[0].Rows.Count;
}
catch
{
RowCount = 0;
}
int CountPages; //共有页数
if (RowCount % objPds.PageSize > 0)
CountPages = RowCount / objPds.PageSize + 1; //有余数
else
CountPages = RowCount / objPds.PageSize; //正好除尽
int CurPage;
if (Request.QueryString["Page"] != null)
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage = 1;
objPds.CurrentPageIndex = CurPage - 1;
lblCurrentPage.Text = "当前页:" + CurPage.ToString();
lblCountPage.Text = "共 " + CountPages + " 页";
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();
//Repeater1.DataSource = this.bindDS().Tables[0];
//Repeater1.DataBind();
}
}
红色部分多加个变量就行了