This is a paging control I wrote, and the following features are:
1. Support Design-time support and two paging modes, in which the effect of the integrated paging mode is as follows:
The effect of the normal paging mode is as follows:
2. Perfect design-time support, including AutoFormat and Design-time panel settings:
How to use:
In 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 ">
<title></title>
<link type= "Text/css" rel= "stylesheet" href= "Style/comm.css"/>
<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= "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"/>
<alternatingrowstyle backcolor= "White"/>
<Columns>
<asp:templatefield headertext= "serial number" >
<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= "addresses"/>
</Columns>
</asp:GridView>
</div>
<div>
<cyclone:aspnetpager id= "AspNetPager1" runat= "server" buttontext= "Go" endpagetext= "last"
firstpagetext= "Home" nextpagetext= "Next" pagesize= "prepagetext=" previous page "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>
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 = "with sea View LAN"});
}
}
protected void Page_changed (object sender, EventArgs e)
{
Binddata ();
}
#region Binding Quiz Paper definition scenario list
<summary>
Query the data you want 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;}
}
}
Other than that:
This page control also contains simple properties, complex properties, custom view state, paging events, creating controls, render controls, Attribute, design-time support, and more complete elements of custom controls, is a good example of learning custom control development, detailed code can be downloaded below: Script Home Download Address