private void Bind() { int pageindex = Convert.ToInt32(Request["page"]); int pagesize = Convert.ToInt32(Request["pagesize"]) == 0 ? 10 : Convert.ToInt32(Request["pagesize"]); int pagecount = 0; List <Links> list = new List <Links>(); LinksDal db = new LinksDal(); list = db.FindPaging(ref pagecount, pageindex, pagesize); if (list.Count == 0 && pageindex > 1) { //大于一页的最后一条被删除,页数-1 重新加载 list = db.FindPaging(ref pagecount, pageindex - 1, pagesize); } hfcount.Value = pagecount.ToString(); rptlist.DataSource = list; rptlist.DataBind(); }
protected void btnfy_Click(object sender, EventArgs e) { int pageinde = Convert.ToInt32(txt1.Text); int pagesize = Convert.ToInt32(txt2.Text); int count = 0; LinksDal db = new LinksDal(); grid2.DataSource = db.FindPaging(ref count, pageinde, pagesize); grid2.DataBind(); Page.ClientScript.RegisterStartupScript(GetType(), "as", "alert('" + count + "')", true); }