ASP. Repeater using the Aspnetpager paging control

Source: Internet
Author: User
One, Aspnetpager pagination control
Paging is one of the most commonly used features in Web applications, and, in ASP., although it comes with a paginated datagrid (ASP. NET 1.1) and a GridView (ASP. NET 2.0) control, its paging functionality is not as satisfactory, such as poor customization, Paging is not possible through URLs, and sometimes we need to DataList and repeater even custom data-bound controls to page, hand-coded pagination code is not only technical difficult, task cumbersome and code reuse rate is very low, So paging has become one of the most frustrating problems for many ASP.
Aspnetpager for the shortcomings of the ASP. NET paging control, a unique solution to solve the problem of paging in ASP., the paging function and the data display function is completely independent of the user to control the data acquisition and display mode, so it can be flexibly applied to any need to implement paging navigation function, For data-bound controls such as GridView, DataList, and Repeater, such as paging, rendering custom paging data, and creating picture-browsing programs, because the Aspnetpager control and data are independent, the data to be paged can come from any data source, such as SQL Databases such as servers, Oracle, Access, MySQL, DB2, and XML files, memory data, or data in the cache, file systems, and so on.
Second, the basic properties:
Alwaysshow:
By default, when the data to be paged has only one page, Aspnetpager defaults to auto-critical instead of displaying any visible content on the page, and when this property value is set to True, Aspnetpager will display the pager element even if the total number of pages is only one page.
Firstpagetext:
Gets or sets the text that is displayed for the first-page button.
Lastpagetext:
Gets or sets the text that is displayed for the last-page button.
NextPageText:
Gets or sets the text that is displayed for the next-page button.
Prevpagetext:
Gets or sets the text displayed for the previous page button.
PageSize:
Gets or sets the number of items to display per page. (This value Gets or sets the number of items that the data rendering control wants to display every time the data is displayed in the data table, Aspnetpager calculates the total pages required for all data, that is, the value of PageCount, based on that value and RecordCount. )
CssClass:
CSS class name applied to the control
Currentpagebuttonclass:
Gets or sets the cascading style sheet (CSS) class for the current pager button of the Aspnetpager page control.
Pageindexboxtype:
or set the display type of the page index box, which can be a text box that allows the user to enter manually and a drop-down box that can be selected only.
Showboxthreshold:
When Showpageindexbox is set to auto (the default) and the total number of pages of data to be paged reaches this value, the page index input text box is automatically displayed, with a default value of 30. This option has no effect when Showpageindexbox is set to never or always.
Three, style style:
===== NetEase Style =====
. Anpager CPB {background: #1F3A87 none repeat scroll 0 0;border:1px solid #CCCCCC; color: #FFFFFF; font-weight:bold;margin : 5px 4px 0 0;padding:4px 5px 0;}
. Anpager a {background: #FFFFFF none repeat scroll 0 0;border:1px solid #CCCCCC; color: #1F3A87; margin:5px 4px 0 0;padding:4p x 5px 0;text-decoration:none}
. Anpager A:hover{background: #1F3A87 None repeat scroll 0 0;border:1px solid #1F3A87; color: #FFFFFF;}
Property settings: cssclass= "Anpager" currentpagebuttonclass= "CPB"
===== Pat NET style =====
. paginator {font:11px Arial, Helvetica, sans-serif;padding:10px 20px 10px 0; margin:0px;}
. paginator a {padding:1px 6px; border:solid 1px #ddd; background: #fff; text-decoration:none;margin-right:2px}
. paginator a:visited {padding:1px 6px; border:solid 1px #ddd; background: #fff; text-decoration:none;}
. paginator CPB {padding:1px 6px;font-weight:bold; Font-size:13px;border:none}
. paginator a:hover {color: #fff; background: #ffa501; Border-color: #ffa501; text-decoration:none;}
Property settings: cssclass= "Paginator" currentpagebuttonclass= "CPB"
===== Thunderbolt Style =====
. pages {color: #999;}
. pages a,. pages. CPB {text-decoration:none;float:left; padding:0 5px; border:1px solid #ddd; background: #ffff; margin: 0 2px; font-size:11px; Color: #000;}
. pages A:hover {background-color: #E61636; color: #fff; border:1px solid #E61636; text-decoration:none;}
. pages. CPB {font-weight:bold; color: #fff; background: #E61636; border:1px solid #E61636;}
Property settings: cssclass= "pages" currentpagebuttonclass= "CPB"
Iv. How to invoke:
index.aspx file

<%@ page language= "C #" autoeventwireup= "true" codefile= "Default2.aspx.cs" inherits= "Default2"%> <%@ Register Assembly= "Aspnetpager" namespace= "Wuqi.webdiyer" tagprefix= "Webdiyer"%> <%@ Register src= "Hand.ascx" Tagname= " Hand "tagprefix=" uc1 "%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 

Index.aspx.cs

Using System; Using System.Collections; Using System.Configuration; Using System.Data; Using System.Linq; Using System.Web; Using System.Web.Security; Using System.Web.UI; Using System.Web.UI.HtmlControls; Using System.Web.UI.WebControls; Using System.Web.UI.WebControls.WebParts; Using System.Xml.Linq; Using System.Data.SqlClient; Using Ghsqlconn; Using Wuqi.webdiyer; Public partial class Default2:System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {SqlConnection conn = db.getconnection (); Conn. Open (); SqlCommand Count = new SqlCommand (); Count.connection = conn; Count.commandtext = "SELECT count (*) from T_SOFTDOWN1"; Aspnetpager1.recordcount = (int) count.executescalar (); Response.Write (Aspnetpager1.recordcount); Conn. Close (); Binddata (); }} public void Binddata () {SqlConnection conn = Db.getconnection (); String sql = "SELECT * from T_softdown1 ORDER by e_i D desc ";//This sentence should be used in large data: Select top Query statement SqlDataAdapter da = new SqlDataAdapter (SQL, CONN); DataSet ds = new DataSet (); Da. Fill (ds, Aspnetpager1.pagesize * (aspnetpager1.currentpageindex-1), aspnetpager1.pagesize, "temptbl"); DataTable dt = ds. tables["Temptbl"]; SOFTDOWN.DATASOURCE=DT; Softdown.databind (); } protected void Aspnetpager1_pagechanged (Object src, EventArgs e) {//aspnetpager1.currentpageindex = E.newpageindex; Binddata (); } }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.