A common paging control, fully supported during design and popular paging mode (source code download is provided)

Source: Internet
Author: User

This is a paging control I wrote with the following functions:

1. Two paging modes are supported during design. The effect of the integrated paging mode is as follows:

The common paging mode has the following effects:

2. Complete Design Support, including automatic format and panel settings during design:

Usage:

On the aspx page:

Copy codeThe Code is as follows: <% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "Default. aspx. cs "Inherits =" Cyclone. customPager. webApplication. _ Default "%>
<% @ Register assembly = "Cyclone. CustomPager. Pager" namespace = "Cyclone. CustomPager. Pager" tagprefix = "Cyclone" %>
<! 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">
<Title> </title>
<Link type = "text/css" rel = "stylesheet" href = "style/comm.css"/>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>

<Asp: gridView ID = "GridView1" runat = "server" AllowPaging = "false" AutoGenerateColumns = "False" CellPadding = "4" ForeColor = "#333333" GridLines = "None" PagerSettings-Visible = "false"
Width = "80%" height = "35" DataKeyNames = "ID">
<FooterStyle BackColor = "#507CD1" Font-Bold = "True" ForeColor = "White"/>
<RowStyle BackColor = "# EFF3FB"/>
<EditRowStyle BackColor = "# 2461BF"/>
<SelectedRowStyle BackColor = "# D1DDF1" Font-Bold = "True" ForeColor = "#333333"/>
<PagerStyle ForeColor = "White" VerticalAlign = "Top" BackColor = "Transparent"/>
<HeaderStyle BackColor = "#507CD1" Font-Bold = "True" ForeColor = "White"/>
<AlternatingRowStyle BackColor = "White"/>
<Columns>
<Asp: TemplateField HeaderText = "no.">
<ItemTemplate>
<% # Container. DataItemIndex + 1%>
</ItemTemplate>
</Asp: TemplateField>
<Asp: BoundField DataField = "ID" HeaderText = "User ID"/>
<Asp: BoundField DataField = "UserName" HeaderText = "UserName"/>
<Asp: BoundField DataField = "Email" HeaderText = "Email"/>
<Asp: BoundField DataField = "Address" HeaderText = "Address"/>
</Columns>
</Asp: GridView>
</Div>
<Div>
<Cyclone: AspNetPager ID = "AspNetPager1" runat = "server" ButtonText = "GO" EndPageText = "last page"
FirstPageText = "Homepage" NextPageText = "Next" PageSize = "15" PrePageText = "previous" OnPageChanged = "Page_Changed" Width = "80%" PageMode = Normal BackColor = "# FFE0C0" BorderColor = "# FFC0C0" BorderStyle = "Solid" BorderWidth = "1px" ForeColor = "#804040">
<ButtonStyle CssClass = "btn1_mouseout" Width = "30px"/>
<TextBoxStyle Width = "30px" CssClass = "blue_rounded"/>
<LabelStyle ForeColor = "Red" Font-Bold = "True"/>
</Cyclone: AspNetPager>

</Div>
</Form>
</Body>
</Html>

In the background code:Copy codeThe Code is as follows: using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Data;
Namespace Cyclone. CustomPager. WebApplication
{
Public partial class _ Default: System. Web. UI. Page
{
Private List <User> _ data = new List <User> ();
Protected override void OnInit (EventArgs e)
{
Base. OnInit (e );
This. GetData ();
}
Protected void Page_Load (object sender, EventArgs e)
{
If (! Page. IsPostBack)
{
BindData ();
This. AspNetPager1.PageIndex = 1;
}
}
Private void GetData ()
{
For (int I = 0; I <1000; I ++)
{
This. _ data. Add (new User {ID = I + 1, Address = "Haidian District, Beijing", Email = "mickjacksonfeng@163.com", UserName = "Ping Hai guanlan "});
}
}
Protected void Page_Changed (object sender, EventArgs e)
{
BindData ();
}
# Region binding exam definition solution list
/// <Summary>
/// Query the required data based on the current page number
/// </Summary>
/// <Param name = "pageIndex"> page number </param>
Private void BindData ()
{
This. AspNetPager1.RecordCount = this. _ data. Count;
List <User> users = this. _ data. Skip (this. AspNetPager1.PageSize * (this. AspNetPager1.PageIndex-1). Take (this. AspNetPager1.PageSize). ToList ();
GridView1.DataSource = users;
GridView1.DataBind ();
}
# Endregion
}
Public class User
{
Public int ID {get; set ;}
Public string UserName {get; set ;}
Public string Email {get; set ;}
Public string Address {get; set ;}
}
}

In addition:

This pagination control also contains simple attributes, complex attributes, custom view status, paging events, creation controls, render controls, attributes, and other fully-equipped custom control elements, it is a good example of learning how to develop custom controls. The detailed code can be downloaded below:

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.