Tina's blog
开心过好每一天! Come on !

 

2.sql 分页

   注意:首先要得到pageSize,pageIndex

   select * from

      (

           select top pageSize * from

               (

                  select top pageSize*pageIndex from Test order by id desc

               )

            as A order by id desc

      )

   Test

 select top  20*4的方式在SQL中取前80条记录,你会失败,因为TOP子句有一个限制,就是TOP num中的num不能是一个计算值或表达式而必须是一个既定的常量-------------------------------------------------------------------------------

  declare @count int

 set @count =2*10

   select * from

      (

           select top 2* from

               (

                  select top @count from Test order by id desc

               )

            as A order by id desc

      )

   Test

 

 

https://files.cnblogs.com/tinachang021/aspnentpager.rar

2.AspnetPage控件使用分页

   1。在sql语句中没有进行分页的情况

        注意使用这个控件的时候,一定要个  this.AspNetPager1.RecordCount 赋值哦,不然这个控件将不显示。

         RecordCount 是总记录数,(数据库里检索出来的所有记录数)。。。 

         StartIndex=this.AspNetPager1.PageSize * (this.AspNetPager1.CurrentPageIndex - 1)

         EnedIndex=this.AspNetPager1.PageSize

          详情看源码:

              

Code

 

这里还要注意哦。。。adapter.Fill(ds.startrecord,maxrecord,"tbName")//它也是取的是当前页的数据

    例如:startRecord=0,maxrecord=10

   那它取的是0-10这10条数据

                 10-20

                  20-30

                 .。。。。

 

时还要注意:AspNetPager控件它有url参数的哦:

         http://localhost:4849/AppointmentMaker/UserProfile/MemberLocation.aspx?page=2

           每次点击分页控件它将会把参数显示到url上:即page就是当前页

 

 

   2.在sql语句中进行分页的情况

  

 

   

posted on 2008-08-15 16:13  Tinachang  阅读(1035)  评论(1编辑  收藏  举报