日期:2014-05-18 浏览次数:20461 次
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindData(); } } void BindData() { string BD_ID = "0"; if (Request.QueryString["Sort"] != null) sort = Request.QueryString["Sort"].ToString(); if (Request.QueryString["BrandID"] != null) BD_ID = Request.QueryString["BrandID"].ToString(); DataSet Ds = ProductProvider.Instance.GetViewMobileBySortExcuteProcdeure(sort,BD_ID); PagedDataSource objPds = new PagedDataSource(); objPds.DataSource =Ds.Tables[0].DefaultView; objPds.AllowPaging = true; objPds.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["z_pagesize"]); int CurPage; if (Request.QueryString["Page"] != null) CurPage = Convert.ToInt32(Request.QueryString["Page"]); else CurPage =0; objPds.CurrentPageIndex = CurPage; ddl_new_price1.DataSource = objPds; ddl_new_price1.DataBind(); int PageCount = objPds.PageCount; if (PageCount > 0) { WritePage(CurPage,PageCount); li_PageCount.Text = " 第<b class='hong12'>" + (CurPage+1).ToString() + "</b> / <span class='hei12'>" + PageCount.ToString() + "</span>页 每页<b class='hei12'>" + objPds.PageSize.ToString() + "</b>款 共<b class='hei12'>" + Ds.Tables[0].Rows.Count.ToString() + "</b> 款"; } else { lb_noFound.Text = "没有找到相关产品!"; } } void WritePage(int PageIndex, int PageCount) { StringBuilder str = new StringBuilder(); string url = Request.RawUrl; if (url.Length > 0) { if (url.IndexOf("_") != -1) { url = url.Substring(url.IndexOf("_")).Replace("#", "%23"); } } li_page.Text = string.Empty; int cnt = 1; if (PageCount > 0) { if (PageIndex != 0) { str.AppendLine("<a class='nor' href='0" + url + "'>首页</a>"); } if (PageIndex < 5) { if (PageIndex > 0) { str.AppendLine("<a class='nor' href='" + (PageIndex - 1) + url + "'>上一页</a>"); } else { str.AppendLine("<a class='nor' disabled>上一页</a>"); } for (int i = 0; i < PageCount; i++) { if (cnt == 6) break; if (i == PageIndex) { str.AppendLine("<a class='act'>" + (i + 1).ToString() + "</a>"); } else { str.AppendLine("<a class='nor' href='" + i + url + "'>" + (i + 1) + "</a>"); } cnt++; } if (PageCount - cnt > 0) { str.AppendLine("<a class='point'>...</a>"); } if (PageIndex < PageCount - 1) { str.AppendLine("<a class='nor' href='" + (PageIndex + 1) + url + "'>下一页</a>"); } else