62,266
社区成员
发帖
与我相关
我的任务
分享
PagedDataSource pds = new PagedDataSource();
protected void Page_Load(object sender, EventArgs e)
{
ShenHe = !Request.QueryString["ShenHe"].ToString().Equals("Yes");
State = Request.QueryString["State"].ToString().Equals("2");
if (!IsPostBack)
{
int maxPage = 0;
ViewState["maxPage"] = maxPage.ToString();
this.lblCurrentPage.Text = "1";
BindInfoType();
BindInfoDetails();
}
}
protected void lbtnFirstPage_Click(object sender, EventArgs e)
{
this.lblCurrentPage.Text = "1";
pds.CurrentPageIndex = 1;
this.BindInfoDetails();
}
protected void lbtnPageUp_Click(object sender, EventArgs e)
{
this.lblCurrentPage.Text = Convert.ToString(Convert.ToInt32(this.lblCurrentPage.Text) - 1);
this.BindInfoDetails();
}
protected void lbtnNextPage_Click(object sender, EventArgs e)
{
this.lblCurrentPage.Text = Convert.ToString(Convert.ToInt32(this.lblCurrentPage.Text) + 1);
this.BindInfoDetails();
}
protected void lbtnLastPage_Click(object sender, EventArgs e)
{
string maxPage = ViewState["maxPage"].ToString();
this.lblCurrentPage.Text = maxPage;
this.lbtnLastPage.Enabled = false;
this.lbtnNextPage.Enabled = false;
this.lbtnPageUp.Enabled = true;
this.lbtnFirstPage.Enabled = true;
this.BindInfoDetails();
}
protected void lbtnResponse_Click(object sender, EventArgs e)
{
if (txtPageIndex.Text.Trim() == "")
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入页数!');</script>");
}
else
{
this.lblCurrentPage.Text = txtPageIndex.Text;
this.BindInfoDetails();
}
}
#region 分页方法
/// <summary>
/// 分页方法
/// </summary>
private void BindInfoDetails()
{
int curPage = Convert.ToInt32(this.lblCurrentPage.Text);
pds.DataSource = QueryBuilder().DefaultView;
pds.AllowPaging = true;
pds.CurrentPageIndex = curPage - 1;
pds.PageSize = 12;
lblCount.Text = pds.DataSourceCount.ToString();
lblCountPage.Text = pds.PageCount.ToString();
ViewState["maxPage"] = lblCountPage.Text;
if (curPage == 1)
{
this.lbtnFirstPage.Enabled = false;
this.lbtnPageUp.Enabled = false;
}
else
{
this.lbtnFirstPage.Enabled = true;
this.lbtnPageUp.Enabled = true;
}
if (curPage == pds.PageCount)
{
this.lbtnNextPage.Enabled = false;
this.lbtnLastPage.Enabled = false;
}
else
{
this.lbtnNextPage.Enabled = true;
this.lbtnLastPage.Enabled = true;
}
rptInfoDetails.DataSource = pds;
rptInfoDetails.DataBind();
}
#endregion