Detailed description of the use of the asp.net paging control [instance download] And asp.net usage

Source: Internet
Author: User

Detailed description of the use of the asp.net paging control [instance download] And asp.net usage

I. Description

The AspNetPager. dll paging control is mainly used for the asp.net webform website. The Code is as follows:

Ii. Code

1. Add a reference on the Default. aspx page of the test page.

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

2. Write a Repeater list control to display data.

<asp:Repeater ID="rptNews" runat="server">  <ItemTemplate>    <li>      <span><%# Eval("time") %></span>      <a href="NewsShow.aspx?id=<%# Eval("id") %>"><%# Access.GetStringNum( Eval("name").ToString(),15) %></a>    </li>  </ItemTemplate></asp:Repeater>

3. Add

<Webdiyer: AspNetPager ID = "AspNetPager1" runat = "server" AlwaysShow = "True" CustomInfoStyle = "FONT-SIZE: 12px "FirstPageText =" Homepage "HorizontalAlign =" Center "inputboxstyle =" width: 19px "LastPageText =" last page "meta: resourcekey = "AspNetPager1" NextPageText = "Next" PageSize = "10" PrevPageText = "previous" Style = "font-size: 14px "Width =" 95% "CssClass =" anpager "CurrentPageButtonClass =" cpb "OnPageChanging =" aspnetpager?pagechanging "ShowBoxThreshold =" 10 "> </webdiyer: AspNetPager>

The PageSize attribute is used to set the number of entries displayed on each page.

4. Bind background code

Access is a test database benchmark class, which is provided to you in the final Demo.

5. Page Control click page number event

// Pagination protected void AspNetPager1_PageChanging (object src, Wuqi. Webdiyer. PageChangingEventArgs e) {this. AspNetPager1.CurrentPageIndex = e. NewPageIndex; ShowNews ();}

The code for the entire page is provided:

Default. aspx

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Default. aspx. cs "Inherits =" Default "%> <% @ Register Assembly =" AspNetPager "Namespace =" Wuqi. webdiyer "TagPrefix =" webdiyer "%> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head runat =" server "> <meta http-equiv =" Content-Type "content =" text/html; charset = UTF-8 "/> <title> asp.net paging Control </title> <link href =" css/css.css "rel =" stylesheet "type =" text/css "/> <style type = "text/css">. aboutcontentnr {width: 100%; height: auto ;} </style> 

Default. aspx. cs

Using System; using System. collections. generic; using System. linq; using System. web; using System. web. UI; using System. web. UI. webControls; using System. data; public partial class Default: System. web. UI. page {protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {ShowNews () ;}// test data source private void ShowNews () {String strSql = String. format ("select * from News order by time asc"); DataTable dtbl = Access. executeDataTable (strSql, null); this. rptNews. dataSource = Access. getPageDataSource (AspNetPager1, AspNetPager1.CurrentPageIndex-1, dtbl); this. rptNews. dataBind () ;}// click the page number event protected void aspnetpager?pagechanging (object src, Wuqi. webdiyer. pageChangingEventArgs e) {this. aspNetPager1.CurrentPageIndex = e. newPageIndex; ShowNews ();}}

Iii. Demo

AspNetPager (dll)

AspNetPage (Demo)

The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!

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.