The user-defined paging control fetches 10 pieces of data from the database each time.

From , 5 Years ago, written in C#, viewed 100 times.
URL https://pastebin.vip/view/64036755
  1. //查数据库使用Linq表达式
  2. /// <summary>
  3.         /// 分页获取数据
  4.         /// </summary>
  5.         /// <param name="PageIndex"></param>
  6.         /// <param name="PageSize"></param>
  7.         /// <param name="total"></param>
  8.         /// <param name="DepartmentID"></param>
  9.         /// <returns></returns>
  10.         public static IList<c_operator> GetListPage(int PageIndex, int PageSize, out int total)
  11.         {
  12.             try
  13.             {
  14.                 using (CertDataContext cdc = new CertDataContext(Tool.sqlstr))
  15.                 {
  16.                     total = cdc.c_operator.Count();
  17.                     return cdc.c_operator.Skip(PageIndex * PageSize).Take(PageSize).ToList();
  18.                 }
  19.             }
  20.             catch (Exception)
  21.             {
  22.                 total = 0;
  23.                 return null;
  24.             }
  25.         }
  26.  
  27. //GriedView绑定数据源
  28.  public void gvBind()
  29.     {
  30.         int count = 0;
  31.         this.GridView1.DataSource = DepartmentBLL.GetAll(Pager1.PageIndex, Pager1.PageSize, out count);
  32.         this.GridView1.DataBind();
  33.         Pager1.ItemCount = count;
  34.         if (count > Pager1.PageSize)
  35.         {
  36.             Pager1.Visible = true;
  37.         }
  38.         else
  39.             Pager1.Visible = false;
  40.     }
  41.  
  42.  

Reply to "The user-defined paging control fetches 10 pieces of data from the database each time."

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website