2010-07-29 6 views
0

Je veux juste découper la pagination toutes les 5 pages parce qu'il y a trop de pages, c'est pourquoi la pagination du fond semble trop bondée.Comment découper la pagination toutes les 5 pages

 int kategoriId = Convert.ToInt32(Request.QueryString["ID"]); 

     using (HEDataContext db = new HEDataContext()) 
     { 

      var productList = (from p in db.KATEGORI_03s 
           where p.kategori_02_id == kategoriId 
           select new 
           { 
           ID= p.ID, 
           Name = p.Name,          
           Bilgi = p.Bilgi, 
           Img1 = p.Img1, 
           Img2 = p.Img2, 
           Count = db.KATEGORI_03s.Count() 
           }).Skip(pg * 9).Take(take); 


      PagedDataSource page = new PagedDataSource(); 
      page.AllowCustomPaging = true; 
      page.AllowPaging = true; 
      page.DataSource = productList; 
      page.PageSize = 9; 

      DLProductsList.DataSource = productList; 
      DLProductsList.DataBind(); 

      if (!IsPostBack) 
      { 
       CreatePagingControl(); 
      } 

     } 




    public void CreatePagingControl() 
    { 

     int totalPageCount = (CountTable()/9) + 1; 
     int ID = Convert.ToInt32(Request.QueryString["ID"]); 
     int pg = Convert.ToInt32(Request.QueryString["pg"]); 
     int kategori_01_id = Convert.ToInt32(Request.QueryString["kategori_01_id"]); 

     string lnk = ""; 

     for (int i = 0; i < (CountTable()/9) + 1; i++){ 


      if (pg == 0) 
      { 
       firstpage.Visible = false; 
       previous.Visible = false; 
      } 


      if (pg == (totalPageCount - 1)) 
      { 
       next.Visible = false; 
       lastpage.Visible = false; 
      } 


      firstpage.NavigateUrl = "Products-List.aspx?kategori_01_id=" + kategori_01_id + "&ID=" + ID + "&pg=0"; 
      previous.NavigateUrl = "Products-List.aspx?kategori_01_id=" + kategori_01_id + "&ID=" + ID + "&pg=" + (pg - 1).ToString(); 
      next.NavigateUrl = "Products-List.aspx?kategori_01_id=" + kategori_01_id + "&ID=" + ID + "&pg=" + (pg + 1).ToString(); 
      lastpage.NavigateUrl = "Products-List.aspx?kategori_01_id=" + kategori_01_id + "&ID=" + ID + "&pg=" + (totalPageCount - 1).ToString(); 


      if (i == pg) 
       lnk += "<span>" + (i + 1).ToString() + "</span>"; 
      else 
       lnk += "<a href='Products-List.aspx?kategori_01_id=" + kategori_01_id + "&ID=" + ID + "&pg=" + i.ToString() + "'>" + (i + 1).ToString() + "</a>"; 


      lnk += "&nbsp;<img src='images/paging-pipe.gif' class='pagingpipe' alt='' />&nbsp;"; 

     } 

     lblPageName.Text = lnk; 

    } 
+0

Y a-t-il des réponses? – Bora

Répondre

1

C'est un problème assez commun, vous pouvez le faire en utilisant un widget jQuery comme celui-ci ci-dessous here

Vous avez juste besoin de fournir la mise en œuvre de back-end pour aller chercher les données dont vous avez besoin.

Questions connexes