分页 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;
            }

        }

 

posted @ 2018-04-19 15:45  你的斗志并没有失去  阅读(107)  评论(0编辑  收藏  举报