Exemple #1
0
        //所有商品
        public void BindData(string BrandId, string CategoryId, string Page)
        {
            Maticsoft.BLL.Products.Product bllp = new Maticsoft.BLL.Products.Product();
            DataSet ds = new DataSet();

            if ((CategoryId != "") || (BrandId != ""))
            {
                ds = bllp.GetListByCategoryID(9, CategoryId, BrandId);
            }
            else
            {
                ds = bllp.GetAllList();
            }
            PagedDataSource objPds = new PagedDataSource();

            objPds.DataSource = ds.Tables[0].DefaultView;
            int record_Count = ds.Tables[0].Rows.Count;
            int page_Size    = 9;
            int totalPages   = int.Parse(Math.Ceiling((double)record_Count / page_Size).ToString());

            int CurPage;

            if (Page != "")
            {
                CurPage = Convert.ToInt32(Page);
            }
            else
            {
                CurPage = 1;
            }

            objPds.AllowPaging      = true;
            objPds.PageSize         = page_Size;
            objPds.CurrentPageIndex = CurPage - 1;

            if (!objPds.IsFirstPage)
            {
                this.lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=1";
                lnkPrev.NavigateUrl       = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + Convert.ToString(CurPage - 1);
            }
            if (!objPds.IsLastPage)
            {
                lnkNext.NavigateUrl      = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + Convert.ToString(CurPage + 1);
                this.lnkLast.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + totalPages.ToString();
            }
            MyList.DataSource = objPds;
            MyList.DataBind();

            //显示数量
            if (objPds.CurrentPageIndex == 0)
            {
                lnkFirst.Enabled = false;
                lnkPrev.Enabled  = false;
                if (totalPages == 1)
                {
                    lnkLast.Enabled = false;
                    lnkNext.Enabled = false;
                }
            }
            else if (objPds.CurrentPageIndex == totalPages - 1)
            {
                lnkLast.Enabled = false;
                lnkNext.Enabled = false;
            }
            this.lblpagesum.Text     = totalPages.ToString();
            this.lblCurrentPage.Text = CurPage.ToString();
            this.lblrowscount.Text   = record_Count.ToString();
        }
Exemple #2
0
        //������Ʒ
        public void BindData(string BrandId, string CategoryId, string Page)
        {
            Maticsoft.BLL.Products.Product bllp = new Maticsoft.BLL.Products.Product();
            DataSet ds = new DataSet();
            if ((CategoryId != "") || (BrandId!=""))
            {
                ds = bllp.GetListByCategoryID(9,CategoryId, BrandId);
            }
            else
            {
                ds = bllp.GetAllList();
            }
            PagedDataSource objPds = new PagedDataSource();
            objPds.DataSource = ds.Tables[0].DefaultView;
            int record_Count = ds.Tables[0].Rows.Count;
            int page_Size = 9;
            int totalPages = int.Parse(Math.Ceiling((double)record_Count / page_Size).ToString());

            int CurPage;
            if (Page != "")
                CurPage = Convert.ToInt32(Page);
            else
                CurPage = 1;

            objPds.AllowPaging = true;
            objPds.PageSize = page_Size;
            objPds.CurrentPageIndex = CurPage - 1;

            if (!objPds.IsFirstPage)
            {
                this.lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=1";
                lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + Convert.ToString(CurPage - 1);
            }
            if (!objPds.IsLastPage)
            {
                lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + Convert.ToString(CurPage + 1);
                this.lnkLast.NavigateUrl = Request.CurrentExecutionFilePath + "?BrandId=" + BrandId + "&Page=" + totalPages.ToString();
            }
            MyList.DataSource = objPds;
            MyList.DataBind();

            //��ʾ����
            if (objPds.CurrentPageIndex == 0)
            {
                lnkFirst.Enabled = false;
                lnkPrev.Enabled = false;
                if (totalPages == 1)
                {
                    lnkLast.Enabled = false;
                    lnkNext.Enabled = false;
                }
            }
            else if (objPds.CurrentPageIndex == totalPages - 1)
            {
                lnkLast.Enabled = false;
                lnkNext.Enabled = false;
            }
            this.lblpagesum.Text = totalPages.ToString();
            this.lblCurrentPage.Text = CurPage.ToString();
            this.lblrowscount.Text = record_Count.ToString();
        }