分页 Database Frist
int Currentpage = 1; int Pagesize = 2; //总条数 int totalRecord = Convert.ToInt32(DB.bBookDBEntities.Book.Count()); public void Data() { lblpage.Text = Currentpage.ToString(); comboBox1.Text = Pagesize.ToString(); dgv.DataSource = b.Book.OrderBy(x => x.BookId).Skip((Currentpage - 1) * Pagesize).Take(Pagesize).ToList(); btnFrist.Enabled = true; btnPre.Enabled = true; btnNext.Enabled = true; btnLast.Enabled = true; if (Currentpage == 1) { btnFrist.Enabled = false; btnPre.Enabled = false; } if(Currentpage== Convert.ToInt32(lbltotal.Text)) { btnNext.Enabled = false; btnLast.Enabled = false; } }