62,268
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["typeid"] != null)
{
string category = Request.QueryString["typeid"].ToString();
categoryId = Convert.ToInt16(category);
}
Execute();
}
}
/// <summary>
/// 数据源
/// </summary>
private static PagedDataSource pds = null;
/// <summary>
/// 分页
/// </summary>
private void Execute()
{
pds = new PagedDataSource();
pds.DataSource = BookManager.GetPartialBooksBySql(categoryId, order, taxis);
pds.AllowPaging = true;
pds.PageSize = 5;
pds.CurrentPageIndex = pageIndex-1;
if (pds.PageCount != 0)
{
lblPageMsg.Text = "第" + (pds.CurrentPageIndex + 1) + "页 共" + pds.PageCount + "页";
this.dlBooks.DataSource = pds;
this.dlBooks.DataBind();
}
else
{
lblPageMsg.Text = "第" + 0 + "页 共" + pds.PageCount + "页";
this.dlBooks.DataSource = null;
this.dlBooks.DataBind();
}
}
/// <summary>
/// 下一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lkBtnNextPage_Click(object sender, EventArgs e)
{
if (pageIndex < pds.PageCount)
{
pageIndex += 1;
Execute();
}
}
/// <summary>
/// 上一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbBtnProvPage_Click(object sender, EventArgs e)
{
if (pageIndex > 1)
{
pageIndex -= 1;
Execute();
}
}
/// <summary>
/// 第一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lkBtnFirPage_Click(object sender, EventArgs e)
{
pageIndex = 1;
Execute();
}
/// <summary>
/// 最后页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lkBtnLastPage_Click(object sender, EventArgs e)
{
pageIndex = pds.PageCount;
Execute();
}
DataPager.SetPageProperties