A more general paging control, complete design-time support and more popular paging mode (provide source download)

Source: Internet
Author: User
Tags object copy string

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



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.