昨天刚向朱哥学了ajax迅速实现分页的方法:
用到了两个文件:
https://files.cnblogs.com/gengxiaochao/分页用的文件.rar

在解决方案下的项目名上右键添加引用-浏览-把这两个文件引用进去,在左面的工具箱-AJAX Extensions右键-选择项-浏览-在Bin中找到AspNetPager.dll打开-AJAX Extensions中就有了AspNetPager控件
拖拽使用生成 :

修改为:
  <webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True" OnPageChanged="AspNetPager1_PageChanged"
                                UrlPaging
="True">
        
</webdiyer:AspNetPager>
在后台代码:

protected void Page_Load(object sender, EventArgs e)
    
{
        AspNetPager1.RecordCount 
= (int)Socut.Data.ExecuteScalar("select count(*) from table");
    }

    
public void Bind()
    
{
        DataSet sea 
= Socut.Data.ExecuteDataSet("select * from table", AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize);
        GridView1.DataSource 
= sea;
        GridView1.DataBind();
    }

    
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    
{
        Bind();
    }
指定了控件给GridView1分页。
Web.config里修改了<appSettings>和<compilation debug="true">
<?xml version="1.0" encoding="utf-8"?>
<!-- 
    注意: 除了手动编辑此文件以外,您还可以使用 
    Web 管理工具来配置应用程序的设置。可以使用 Visual Studio 中的
     “网站”->“Asp.Net 配置”选项。
    设置和注释的完整列表在 
    machine.config.comments 中,该文件通常位于 
    \Windows\Microsoft.Net\Framework\v2.x\Config 中
-->
<configuration>
  
<appSettings>
    
<add key="SocutDataLink" value="Server=SEA\SQLEXPRESS;Initial Catalog=sea;Integrated Security=True"/>
  
</appSettings>
    
    
<connectionStrings>
        
<add name="seaConnectionString1" connectionString="Data Source=SEA\SQLEXPRESS;Initial Catalog=sea;Integrated Security=True"
            providerName
="System.Data.SqlClient" />
    
</connectionStrings>
    
<system.web>
        
<!-- 
            设置 compilation debug="true" 将调试符号插入
            已编译的页面中。但由于这会 
            影响性能,因此只在开发过程中将此值 
            设置为 true。
        
-->
      
<compilation debug="true">
        
<assemblies>
          
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        
</assemblies>
      
        
<!--
            通过 <authentication> 节可以配置 ASP.NET 使用的 
            安全身份验证模式,
            以标识传入的用户。 
        
-->
      
</compilation>
        
<authentication mode="Forms" />
        
<!--
            如果在执行请求的过程中出现未处理的错误,
            则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
            开发人员通过该节可以配置
            要显示的 html 错误页
            以代替错误堆栈跟踪。

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        
-->
    
</system.web>
</configuration>


向数据库插入十万条数据:
  DECLARE   @VA   INT  
set @VA=1
  
WHILE   @VA<100000  
  
BEGIN  
  
INSERT   INTO   [sea]   VALUES(@VA)  
set @VA=@VA+1
  
END   
控件瞬间完成了分页。
posted on 2007-09-18 10:42  超少  阅读(269)  评论(2编辑  收藏  举报