AspNetPager这个控件我感觉很好用
可我每次绑定时都是把所有的数据都给读出来的,这样对小数据来说是没问题,要是有大的数据就死定了
我现在想要一个SQL语句就是,先给AspNetPager绑定,把纪录总数给AspNetPager,通过AspNetPager当前页数在去数据库读数据绑定显示控件
这样我想就会很快了吧
请高人帮忙 

解决方案 »

  1.   

    你说得,就是根据aspnetpager的页码范围,从数据库中读取需要的数据。
    CREATE procedure Get_Product 
    (@startIndex int, 
    @endIndex int, 
    @docount bit) 
    as 
    set nocount on 
    if(@docount=1) 
    select count(*) AS Counts from Product 
    else 
    begin 
    declare @indextable table(id int identity(1,1),nid int) 
    set rowcount @endIndex 
    insert into @indextable(nid) select ID from Product  order by ID desc 
    select * from Product O,@indextable t where O.ID=t.nid 
    and t.id between @startIndex and @endIndex order by t.id 
    end 
    set nocount off GO 
    这个存储过程就是用来实现你说的功能的。
    http://topic.csdn.net/u/20081025/09/1eaff677-7cb2-4a26-9c6d-cd9202932f06.html
      

  2.   

    .....................o888888o.o88888888o.              
    .................8888888888888888888888888o.              
    ...............888::::888888888888888888888888o.              
    .............88::::::::88888888888888888888888888o.              
    ...........o8:::::::::888::顶88888888888888888888888.              
    ..........8888:8::::::8:::::::::顶88888888888888888888.              
    .........8888::::8888::::::::::::::::顶88888888888  88              
    ........8888:::888888888::::::::::::::::顶888888888  8              
    .......88.88888888888888888:::::::::::::顶88888888888              
    ......88..888888888888888888:::::::::::顶88888888888888              
    ......88.888888888888888888888::::::::顶88888888888888888              
    ......8..8888888888888888888888::::::顶88888888888888888888              
    ........8888888888888888::88888:::::顶8888888888888888888888              
    ......88888888888888888::::8888::::顶8888888888888888  8888              
    .....88888888888888888::::8888::::顶:8::***::888888888  888              
    ....88888888888888888::::888:::::顶::::****::888888888  88              
    ..888888888888888888::::88::::::顶:::::::::::::888888888 88              
    .8888888888888888888::::8::::::顶:::::::::::::顶888888888 88              
    888...8888888888::88::::8:::::顶:::8oo8::::::88888888888888 8              
    88...88888888888:::8:::::::::顶:::::::::::::88888888888888888              
    .8..8888888888888:::::::::::顶::"8888888":::顶88888888888888888              
    ..8888888888::888::::::::::顶:::::"8*8"::::顶88888888888888888888              
    .888888888:::::88:::::::::顶88::::::::::::顶88888888888888888888888              
    8888888888:::::8:::::::::顶88888::::::::顶888888888888888888888888888              
    888888888:::::8:::::::::顶8888888ooooo顶8888888888888888888888888888888              
    888888.顶::::::::::::::顶8888888888::::::顶8888888888888888  888888888              
    8888..顶:::::::::::::::顶88888888888::::::顶8888888888888888 8888888                
    88888顶:::::::::::::顶88888888888888888::::::顶8888888888888   88888              
    ...88.顶:::::::::::::8888:88888888888888888:::::顶顶888888888   8888              
    ...88.顶:::::::::::8888顶::88888::888888888888:::::顶顶88888   888              
    ...8...顶::::::::::8888顶:::8888:::::88888888888::::::顶顶88   888              
    .......8顶:::::::8888顶:::::888:::::::88:::8888888:::::::顶顶  88              
    ......88顶:::::::8888顶::::::88:::::::::8:::::888888::::::::顶顶 88              
    .....8888顶:::::888顶:::::::::88::::::::::顶::::8888::::::::::::顶 8              
    ....88888:顶::::888顶::::::::::8:::::::::::顶::::888::::::::::::::顶              
    ...88.888:顶:::888:顶::::::::::8::::::::::::顶::888::::::::::::::::顶              
    ...8.88888顶:::88::顶::::::::::::::::::::::::顶:88::::::::::::::::::顶              
    .....88888顶:::88::顶:::::::::::::::::::::::::顶88:::::::::::::::::::顶              
    .....88888顶:::88::顶:::::::::::::::::::::::::顶:8::::::::::::::::::::顶              
    ....888888顶::::8::顶::::::::::::::8888::::::::顶8::::::::::::8888:::::顶              
    ....88888..顶:::8::顶顶:::::::::::888888:::::::顶::::::::::::888888::::顶              
    ....8888...顶顶:::::顶顶::::::::::888888:::::::顶顶::::::::::888888::::顶              
    ....8888....顶:::::::顶顶::::::::::8888:::::::顶顶顶::::::::::8888::::顶              
    .....888....顶顶::::::顶顶顶:::::::::::::::::顶顶::顶::::::::::::::::顶              
    ......88.....顶::::::::顶顶顶顶:::::::::::顶顶顶:::顶顶:::::::::::::顶              
    .......88....顶顶:::::::::顶顶顶顶顶顶顶顶顶顶:::::::顶顶顶顶顶顶顶顶              
    ........88....顶顶::::::::::::顶顶顶顶顶顶顶::::::::::::顶顶顶顶顶            
    ........88....顶顶::::::::::::顶顶顶顶顶顶顶::::::::::::顶顶顶顶              
    .........88...8顶顶::::::::::::::::::::::::::::::::::::::::顶              
    ..........8...88顶顶::::::::::::::::::::::顶:::顶::::::::::顶              
    ..............888顶顶::::::::::::::::::顶顶::::::顶顶::::::顶              
    .............88888顶顶:::::::::::::::顶顶顶:::::::顶顶:::::顶              
    .............888888顶顶:::::::::::::顶顶顶:::::::::顶顶:::顶              
    ............88888888顶顶:::::::::::顶顶顶:::::::::::顶:::顶              
    ...........88.8888888.顶::::::::顶顶顶::::::::::::::顶::顶              
    ...........8..888888..顶::::::顶顶:::::::::::::::::顶::顶              
    ..............888888..顶:::::顶:::::::::::::::::::顶::顶顶              
    .............888888...顶::::顶::::::::::::::::::::::::顶顶              
    .............888888...顶::::顶::::::::::::::::::::::::顶:顶              
    .............88888...顶::::::::::::::8::::::::::::::::顶::顶              
    ............88888...顶:::::::::::::::88::::::::::::::::顶::顶              
    ...........88888...顶::::::::::::::::8::::::::::::::::::顶::顶              
    ..........88888...顶:::::顶:::::::::::::::::::::顶::::::::顶::顶              
    ..........8888...顶:::::顶:::::::::::::::::::::::顶顶::::::顶::顶              
    .........8888...顶:::::顶:::::::::::::::::::::::顶顶顶:::::::顶:顶              
    ........888....顶:::::顶顶::::::::::::::::::::::顶顶顶::::::::顶:顶              
    ......8888....顶::::::顶顶:::::::::::::::::::::顶顶顶::::::::: 顶:顶              
    .....888......顶:::::顶:::::::::::::::::::::::顶顶::::::::::::::顶:顶              
    ..8888.......顶::::::::::::::::::::::::::::::顶::::::::::::::::::顶:顶              
    .............顶::::::::::::::::::::::::::::::::::::::::::::::::::顶:顶              
    ............顶::::::::顶:::::::::::::::::::::::::::::::::::::::::顶:顶              
    ............顶::::::::顶:::::::::::::::::顶::::::::::::::::::::::顶:顶              
    ...........顶::::::::::顶::::::::::::::顶::::::::::::::::::::::::顶:顶              
    ...........顶:::::::::::顶8::::::::8:顶:::::::::::::::::::::::::顶:顶              
    ...........顶::::::::::::888hole888顶:::::::::::::::::::::::::::顶:顶              
    ...........顶:::::::::::::88888888顶:::::::::::::::::::::::::::顶:顶              
    ...........顶::::::::::::::888888顶::::::::::::::::::::::::::::顶:顶              
    ...........顶:::::::::::::::88888顶:::::::::::::::::::::::::::顶:顶              
    ...........顶:::::::::::::::::88顶::::::::::::::::::::::::::::顶顶              
    ...........顶:::::::::::::::::::顶:::::::::::::::::::::::::::顶顶              
    ...........顶:::::::::::::::::::顶::::::::::::::::::::::::::顶顶              
    ............顶:::::::::::::::::顶::::::::::::::::::::::::::顶顶              
    ............顶:::::::::::::::::顶::::::::::::::::::::::::::顶              
    .............顶:::::::::::::::顶::::::::::::::::::::::::::顶              
    .............顶:::::::::::::::顶:::::::::::::::::::::::::顶              
    ..............顶:::::::::::::顶:::::::::::::::::::::::::顶              
    ..............顶:::::::::::::顶:::::::::::::::::::::::顶              
    ...............顶:::::::::::顶:::::::::::::::::::::::顶              
    ...............顶:::::::::::顶::::::::::::::::::::::顶              
    ................顶:::::::::顶::::::::::::::::::::::顶              
    ................顶:::::::::顶:::::::::::::::::::::顶              
    .................顶:::::::顶:::::::::::::::::::::顶              
    ..................顶::::::顶::::::::::::::::::::顶              
    ..................顶:::::顶::::::::::::::::::::顶              
    ...................顶:::顶::::::::::::::::::::顶            
    ...................顶::顶::::::::::::::::::::顶              
    ....................顶:顶:::::::::::::::::::顶              
    ....................顶顶:::::::::::::::::::顶              
    ....................顶顶::::::::::::::::::顶
      

  3.   

    用存儲過程吧。ALTER proc [dbo].[usp_daily_work_select]
    @flag int,
    @owner nvarchar(50),
    @status nvarchar(50),
    @project nvarchar(50),
    @startdate1 datetime,
    @startdate2 datetime,
    @duedate1 datetime,
    @duedate2 datetime,
    @description nvarchar(2000),
    @updatedatetime datetime,
    @updatename nvarchar(50),
    @type nvarchar(50),
    @item nvarchar(50),
    @code nvarchar(50),
    @pagesize int,
    @pageindex int
    AS
    Begin--查询时显示的资料
    if(@flag=1)
    begin
    if(@status='Delete')
    begin
    with temptbl as
    (
    select ROW_NUMBER()over(order by project asc,(right([Code],5)) desc) AS Number, 
    dw.[No],dw.Project,dw.Item,dw.Code,dw.[Type],dw.[Description (purpose/value)],dw.Status,dw.[%],
            Convert(Varchar(10),dw.[Start Date],120)AS [Start Date],Convert(Varchar(10),dw.[Due Date],120)AS [Due Date],dw.Owner,dw.[Day/Hour],dw.Comment,dw.Updatedatetime,dw.UpdateName
    from daily_work dw
    where dw.Status='Delete'
    and dw.Item like '%'+@item+'%'
    and dw.Owner like ''+@owner+'%' 
    and dw.Status like '%'+@status+'%'
    and dw.Project like '%'+@project+'%'
    and ((dw.[Start Date] between @startdate1 and @startdate2) or dw.[Start Date] IS null)
    and ((dw.[Due Date] between @duedate1 and @duedate2 )or dw.[Due Date] IS null)
    and dw.[Description (purpose/value)] like '%'+@description+'%'
    )
    select * from temptbl where Number>=((@pageindex-1)*@pagesize+1)
    and Number<=(@pageindex*@pagesize) order by project asc,(right([Code],5)) desc
    end長是長了點,絕對正確,我自己寫的,沒改就貼給你,你試試。
      

  4.   

    这两句比较重要
    select * from temptbl where Number>=((@pageindex-1)*@pagesize+1)
    and Number<=(@pageindex*@pagesize) order by project asc,(right([Code],5)) desc
      

  5.   

    AspNetPager 72Samples 控件就是针对大数据的啊,可好用了还有各种控件的例子。
      

  6.   

    http://www.webdiyer.com/AspNetPager/default.aspx