At the invitation of some friends, I will write some detailed instructions on using and modifying sqlpager:
1. To use sqlpager, first import the modified sqlpager. dll.
2. At the front-end of the page: <% @ Register tagprefix = " PC3 " Namespace = "Hlsqlpager " Assembly = " Sqlpager " %> < C0: sqlpager ID = "Sqlpager1" Runat = "Server" Connectionstring = "Server = (local); database = test; uid = sa; Pwd = 123"
Itemsperpage = "12" Controltopaginate = "DG" Width = "250px" Sortmode = "DESC" > </ C0: sqlpager > < ASP: DataGrid ID = "DG" Runat = "Server" Width = "100%" Borderwidth = "0" Showheader = "False" Autogeneratecolumns = "False" >
< Itemstyle Borderwidth = "0" > </ Itemstyle >
< Columns >
</ Columns >
</ ASP: DataGrid > < C0: sqlpager ID = "Sqlpager2" Runat = "Server" Connectionstring = "Server = (local); database = test; uid = sa; Pwd = 123"
Itemsperpage = "12" Controltopaginate = "DG" Width = "250px" > </ C0: sqlpager >
Note: controltopaginate= "DG"The DG here is the name of the control you want to bind data to (only the DataGrid or datalist can be used)
3. backend Data Binding Function /**/ /// <Summary>
/// Bind sqlpager data to a specified control
/// </Summary>
/// <Param name = "SQL"> SQL query </Param>
/// <Param name = "sortfield"> Sorting Field </Param>
/// <Param name = "sortmode"> Sorting Method </Param>
Private Void Bindgrid ( String SQL, String Sortfield, String Sortmode)
{
Sqlpager1.selectcommand = SQL;
Sqlpager2.selectcommand = SQL;
Sqlpager1.sortfield = Sortfield;
Sqlpager2.sortfield = Sortfield;
If (Sortmode = " Desc " )
{
Sqlpager1.sortmode=Hlsqlpager. sortmode. DESC;
Sqlpager2.sortmode=Hlsqlpager. sortmode. DESC;
}
Else
{
Sqlpager1.sortmode=Hlsqlpager. sortmode. ASC;
Sqlpager2.sortmode=Hlsqlpager. sortmode. ASC;
}
Hlsqlpager. Sqlpager sqlp = New Hlsqlpager. Sqlpager ();
This . Databind ();
}
4. Two sqlpager links Private Void Sql1_pager ( Object Sender, hlsqlpager. pagechangedeventargs E)
{
Sqlpager2.currentpageindex=Sqlpager1.currentpageindex;
Sqlpager2.databind ();
}
Private Void Sql2_pager ( Object Sender, hlsqlpager. pagechangedeventargs E)
{
Sqlpager1.currentpageindex=Sqlpager2.currentpageindex;
Sqlpager1.databind ();
}
Private Void Initializecomponent ()
{ This . Sqlpager1.pageindexchanged + = New Hlsqlpager. Sqlpager. pagechangedeventhandler ( This . Sql1_pager );
This . Sqlpager2.pageindexchanged + = New Hlsqlpager. Sqlpager. pagechangedeventhandler ( This . Sql2_pager );
This . Load + = New System. eventhandler ( This . Page_load );
}
5. Cut the Graph
6. Description
You can modify sqlpager as needed
Original version: Download the source code of this article (English)