I just learned from Zhu Ge yesterday how to quickly implement paging through Ajax:
Two files are used:
Http://files.cnblogs.com/gengxiaochao/the file used for page sharding. rar
In the solution, right-click the project name and choose add reference> browse to reference the two files, right-click the toolkit-Ajax extensions on the left and choose "select item"> "Browse"> "aspnetpager" in "bin. open the DLL-Ajax extensions and the aspnetpager control is available.
Drag and Drop to generate:
To:
< Webdiyer: aspnetpager ID = "Aspnetpager1" Runat = "Server" Alwaysshow = "True" Onpagechanged = "Aspnetpager1_pagechanged"
Urlpaging = "True" >
</ Webdiyer: aspnetpager >
In the backgroundCode:
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 ();
}
Controls are specified to pagination to gridview1.
<Etettings> and <compilation DEBUG = "true"> are modified in Web. config. <? XML version = "1.0" encoding = "UTF-8" ?>
<! --
Note: In addition to manually editing this file, you can also use
Web management tools to configure application settings. You can use
"Website"-> "ASP. NET configuration" option.
The complete list of settings and comments is displayed in
In machine. config. Comments, this file is usually located in
\ 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 >
<! --
Set compilation DEBUG = "true" to insert the debugging symbol
Compiled pages. However, this
Performance is affected, so this value is only available during development.
Set to 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 >
<! --
In the <authentication> section, you can configure
Security Authentication mode,
To identify the user.
-->
</ Compilation >
< Authentication Mode = "Forms" />
<! --
If an unprocessed error occurs during request execution,
You can configure the corresponding processing steps in the <mermerrors> section. Specifically,
This section allows developers to configure
HTML error page to be displayed
To replace the error stack trace.
<Customerrors mode = "remoteonly" defaultredirect = "genericerrorpage.htm">
<Error statuscode = "403" Redirect = "noaccess.htm"/>
<Error statuscode = "404" Redirect = "filenotfound.htm"/>
</Customerrors>
-->
</ System. Web >
</ Configuration >
Insert 100,000 data records into the database: Declare @ Va Int
Set @ Va = 1
While @ Va < 100000
Begin
Insert Into [ Sea ] Values ( @ Va )
Set @ Va = @ Va + 1
End
Controls instantly complete paging.