protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["surrentPage"] = 0; UA mUA = new UA(); int PageSum = mUA.GetPage(); int CurrentPage = Convert.ToInt32(ViewState["surrentPage"]); ShowPages.Text = "第" + (CurrentPage + 1).ToString() + "页/共" + PageSum + "页"; divide mdv = new divide(); this.UserList.DataSource = mdv.UserShow(Convert.ToInt32(ViewState["surrentPage"])); this.UserList.DataBind(); } }
/// <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.UserList.DataSource = mdv.UserShow(Convert.ToInt32(ViewState["surrentPage"])); this.UserList.DataBind(); } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('" + "已经是第一页!!" + "');</script> "); } UA mUA = new UA(); int PageSum = mUA.GetPage(); int CurrentPage = Convert.ToInt32(ViewState["surrentPage"]); ShowPages.Text = "第" + (CurrentPage + 1).ToString() + "页/共" + PageSum + "页"; }