protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["surrentPage"] = 0; divide mdv = new divide(); this.AdminList.DataSource = mdv.AdminShow(Convert.ToInt32(ViewState["surrentPage"])); this.AdminList.DataBind(); SA mSA = new SA(); int PageSum = mSA.GetPage(); int CurrentPage = Convert.ToInt32(ViewState["surrentPage"]); ShowPages.Text = "第" + (CurrentPage + 1).ToString() + "页/共" + PageSum + "页"; } }
/// <summary> /// 上一页 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void last_Click(object sender, EventArgs e) { if (Convert.ToInt32(ViewState["surrentPage"]) > 0) { ViewState["surrentPage"] = Convert.ToInt32(ViewState["surrentPage"]) - 1; divide mdv = new divide(); this.AdminList.DataSource = mdv.AdminShow(Convert.ToInt32(ViewState["surrentPage"])); this.AdminList.DataBind(); } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + "已经是第一页!!" + "');</script> "); } SA mSA = new SA(); int PageSum = mSA.GetPage(); int CurrentPage = Convert.ToInt32(ViewState["surrentPage"]); ShowPages.Text = "第" + (CurrentPage + 1).ToString() + "页/共" + PageSum + "页"; }