This control can be applied to the GridView, Repeater, DataGrid, DataList... almost all.. net data binding controls are paginated, and all data binding components can use stored procedures or SQL statements directly. This control has no interference! This control has a good user interface, can change various styles as needed, with css control effect is better!
1. Paging style:
2. How to use:
Add: AspNetAjaxPager. dll reference under the bin directory
Aspx file content:
Copy codeThe Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs" Inherits = "Demo. _ Default" %>
<% @ Register Namespace = "AspNetAjaxPager" TagPrefix = "ajax" Assembly = "AspNetAjaxPager" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<! --
// ================================================ ======================================
// Company Name: savage Network Studio (http://www.wildren.com)
// Machine name: WWW-BBE63F97A80
// Name of the registered organization: Lenovo (Beijing) Limited
// CLR version: 2.0.50727.1433
// File name: Default. aspx
// Creator: Shao long
// Creation Time: 16:29:49
// Program version: Version 1.0
// Function Description: AspNetAjaxPager Demo
// Modify record:
// ================================================ ======================================
-->
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> AspNetAjaxPager Demo </title>
<Link href = "css/style.css" type = "text/css" rel = "stylesheet"/>
<Script src = "js/jquery-1.3.2.min.js" type = "text/javascript"> </script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Div id = "pannel">
<Div class = "PagingWrapper">
<Asp: Repeater ID = "Repeater1" runat = "server">
<HeaderTemplate>
<Table border = "0" cellpadding = "0" cellspacing = "0" class = "stripe">
<Tr>
<Td> NO. </td>
<Td> name </td>
<Td> age </td>
</Tr>
</HeaderTemplate>
<ItemTemplate>
<Tr>
<Td>
<% # Eval ("id") %>
</Td>
<Td>
<% # Eval ("name") %>
</Td>
<Td>
<% # Eval ("age") %>
</Td>
</Tr>
</ItemTemplate>
<FooterTemplate>
</Table>
</FooterTemplate>
</Asp: Repeater>
</Div>
<Div>
<Ajax: AjaxPager ID = "Pager1" runat = "server" AjaxContainerID = "pannel" PagedControlID = "Repeater1" Align = "left"
BackColor = "Transparent" BorderColor = "Red" BorderWidth = "0px" DescriptionText = "in use:" GotoButtonValue = "go"
CssClass = "navi" IsGotoSelectVisible = "False" IsGotoTextBoxVisible = "False" LeftPageSize = "0" RightPageSize = "0" CurrentNumberBgColor = "White"/>
<Br/>
<Br/>
</Div>
<Ajax: AjaxPager ID = "AjaxPager1" runat = "server" AjaxContainerID = "pannel" PagedControlID = "Repeater1" Align = "left"
BackColor = "Transparent" BorderColor = "Red" BorderWidth = "0px" DescriptionText = "" GotoButtonValue = "go to" CssClass = "navi"
RecordCount = "1500" IsGotoSelectVisible = "False" IsGotoTextBoxVisible = "False"/>
<Br/>
<Br/>
<Ajax: AjaxPager ID = "AjaxPager2" runat = "server" AjaxContainerID = "pannel" PagedControlID = "Repeater1" Align = "left"
BackColor = "Transparent" BorderColor = "Red" BorderWidth = "0px" DescriptionText = "" GotoButtonValue = "go to" CssClass = "navi"
RecordCount = "1500" IsGotoSelectVisible = "False"/>
<Br/>
<Br/>
<Ajax: AjaxPager ID = "AjaxPager3" runat = "server" AjaxContainerID = "pannel" Align = "left"
BackColor = "Transparent" BorderColor = "Red" BorderWidth = "0px" CssClass = "navi" DescriptionText = ""
GotoButtonValue = "go"
PagedControlID = "Repeater1" RecordCount = "1500"/>
<Br/>
<Br/>
<Ajax: AjaxPager ID = "AjaxPager4" runat = "server" AjaxContainerID = "pannel" Align = "left"
BackColor = "DarkGray" BorderColor = "Red" BorderWidth = "1px" CssClass = "navi" DescriptionText = ""
GotoButtonValue = "go to" IsGotoSelectVisible = "False"
PagedControlID = "Repeater1" RecordCount = "1500" CellSpacing = "1px"/>
<Br/>
<Br/>
<Br/>
<Ajax: AjaxPager ID = "AjaxPager5" runat = "server" AjaxContainerID = "pannel" Align = "left"
BackColor = "Transparent" BorderColor = "Red" BorderWidth = "0px" CssClass = "navi" DescriptionText = ""
GotoButtonValue = "go to" IsGotoTextBoxVisible = "False"
PagedControlID = "inherit" RecordCount = "1500" LinkIsText = "False" NextLink = "img/next.gif" FirstLink = "img/first.gif" LastLink = "img/last.gif" previuslink = "img /previous.gif "/>
<Br/>
<Br/>
<Ajax: AjaxPager ID = "AjaxPager6" runat = "server" AjaxContainerID = "pannel" Align = "left"
BackColor = "Transparent" BorderColor = "Red" BorderWidth = "0px" CssClass = "navi" DescriptionText = ""
GotoButtonValue = "go to" IsGotoSelectVisible = "False" IsGotoTextBoxVisible = "False"
PagedControlID = "Repeater1" RecordCount = "1500" CurrentNumberBgColor = "Yellow" CurrentPageColor = "Lime" LinkNumberWidth = "20px"/>
<Br/>
<Br/>
</Div>
</Div>
</Form>
</Body>
</Html>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ (". Stripe tr"). mouseover (function (){
$ (This). addClass ("over") ;}). mouseout (function (){
$ (This). removeClass ("over ");})
$ (". Stripe tr: even"). addClass ("alt ");
});
</Script>
. Cs file content:
Copy codeThe Code is as follows:
// ================================================ ======================================
// Company Name: savage Network Studio (http://www.wildren.com)
// Machine name: WWW-BBE63F97A80
// Name of the registered organization: Lenovo (Beijing) Limited
// CLR version: 2.0.50727.1433
// File name: Default. aspx. cs
// Creator: Shao long
// Creation Time: 16:29:49
// Program version: Version 1.0
// Function Description: AspNetAjaxPager Demo
// Modify record:
// ================================================ ======================================
Using System;
Using System. Data;
Using System. Configuration;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Web. UI. HtmlControls;
Using System. Data. OleDb;
Using AspNetAjaxPager. Delegate;
Namespace Demo
{
Public partial class _ Default: System. Web. UI. Page
{
Private OleDbConnection conn;
Private OleDbCommand cmd;
Protected void Page_Load (object sender, EventArgs e)
{
If (! Page. IsPostBack)
{
This. BindData (this. Pager1.CurrentPageIndex, this. Pager1.PageSize );
}
Else
{
/// When you click the page navigation, the binding event is triggered by the control proxy object to re-display data.
This. Pager1.OnPageIndexChanged = new PageIndexChangedDelegate (BindData );
}
}
/// <Summary>
/// Bind Repeater data
/// </Summary>
/// <Param name = "PageIndex"> </param>
/// <Param name = "PageSize"> </param>
Public void BindData (int PageIndex, int PageSize)
{
Int intStartIndex = (PageIndex-1) * PageSize + 1;
Int intEndIndex = PageIndex * PageSize;
Conn = new OleDbConnection ();
Conn. ConnectionString = @ "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" + Server. MapPath ("~ /App_data/db. mdb ");
Cmd = conn. CreateCommand ();
Conn. Open ();
/// This part can be changed to Stored Procedure pagination without any impact on the control
Cmd. CommandText = "select count (*) from students ";
Int totalCount = (int) cmd. ExecuteScalar ();
Cmd. CommandText = string. Format ("select * from students where id >={ 0} and id <={ 1}", intStartIndex, intEndIndex );
DataSet ds = new DataSet ();
OleDbDataAdapter da = new OleDbDataAdapter (cmd. CommandText, conn );
Da. Fill (ds );
This. Pager1.RecordCount = totalCount;
This. Repeater1.DataSource = ds;
This. Repeater1.DataBind ();
}
}
}