private void Bind(string goodsName, int page, int count) { string nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); int totalCount = tbgDal.GetAllGoodsCount(nick, goodsName); int TotalPage = totalCount % count != 0 ? (totalCount / count) + 1 : totalCount / count; //总页数 IList <GoodsInfo> list = tbgDal.GetAllGoods(nick, goodsName, page, count); lblCurrentPage.Text = "共" + totalCount.ToString() + "条记录 当前页:" + page + "/" + (TotalPage == 0 ? 1 : TotalPage); lnkFrist.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1&"; if (page > 1) { lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(page - 1); } if (page != TotalPage && TotalPage != 0) { lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(page + 1); } lnkEnd.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + (TotalPage == 0 ? 1 : TotalPage); Rpt_GoodsList.DataSource = list; Rpt_GoodsList.DataBind(); }
private void Bind(string goodsName, string className) { int TotalCount = 0; //总记录数 int TotalPage = 1; //总页数 string nick = ""; if (Request.Cookies["nick"] != null) { nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); //"nick"; } else { nick = Session["snick"].ToString(); } int page = 1; try { page = int.Parse(Request.QueryString["Page"]); if (ViewState["page"] != null) { page = int.Parse(ViewState["page"].ToString()); ViewState["page"] = null; } } catch { } IList <GoodsInfo> list = goodsDal.SearchGoods(nick, goodsName, className); TotalCount = list.Count; pds.DataSource = list; pds.AllowPaging = true; pds.PageSize = 10; if (TotalCount == 0) { TotalPage = 1; } else { if (TotalCount % pds.PageSize == 0) { TotalPage = TotalCount / pds.PageSize; } else { TotalPage = TotalCount / pds.PageSize + 1; } } pds.CurrentPageIndex = page - 1; lblCurrentPage.Text = "共" + TotalCount.ToString() + "条记录 当前页:" + page + "/" + TotalPage; string paramArray = string.Empty; if (!string.IsNullOrEmpty(goodsName)) { paramArray += "&goods=" + goodsName; } if (!string.IsNullOrEmpty(className)) { paramArray += "&gclass=" + className; } lnkFrist.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1" + paramArray; if (!pds.IsFirstPage) { lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + (page - 1) + paramArray; } if (!pds.IsLastPage) { lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + (page + 1) + paramArray; } lnkEnd.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + TotalPage + paramArray; Rpt_GoodsList.DataSource = pds; Rpt_GoodsList.DataBind(); }