一個(gè)比較通用的分頁(yè)控件,完整的設(shè)計(jì)時(shí)支持和比較流行的分頁(yè)模式(提供源碼下載)
這是我寫(xiě)的一個(gè)分頁(yè)控件,功能如下:
1.支持設(shè)計(jì)時(shí)支持和兩種分頁(yè)模式,其中綜合分頁(yè)模式的效果如下:

普通分頁(yè)模式的效果如下:

2.完善的設(shè)計(jì)時(shí)支持,包括自動(dòng)套用格式和設(shè)計(jì)時(shí)面板設(shè)置:



使用方法:
在aspx頁(yè)面中:
<%@ 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="序號(hào)">
<ItemTemplate>
<%# Container.DataItemIndex+1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" HeaderText="用戶ID" />
<asp:BoundField DataField="UserName" HeaderText="用戶名" />
<asp:BoundField DataField="Email" HeaderText="Email" />
<asp:BoundField DataField="Address" HeaderText="地址" />
</Columns>
</asp:GridView>
</div>
<div>
<Cyclone:AspNetPager ID="AspNetPager1" runat="server" ButtonText="GO" EndPageText="末頁(yè)"
FirstPageText="首頁(yè)" NextPageText="下一頁(yè)" PageSize="15" PrePageText="上一頁(yè)" 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>
在后臺(tái)代碼中:
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 = "北京市海淀區(qū)", Email = "mickjacksonfeng@163.com", UserName = "憑海觀瀾" });
}
}
protected void Page_Changed(object sender, EventArgs e)
{
BindData();
}
#region 綁定試卷定義方案列表
/// <summary>
/// 根據(jù)當(dāng)前頁(yè)碼查詢需要的數(shù)據(jù)
/// </summary>
/// <param name="pageIndex">頁(yè)碼</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; }
}
}
另外:
本分頁(yè)控件還包含簡(jiǎn)單屬性,復(fù)雜屬性,自定義視圖狀態(tài),分頁(yè)事件,創(chuàng)建控件,render控件,Attribute,設(shè)計(jì)時(shí)支持等比較齊全的自定義控件的元素,是個(gè)不錯(cuò)學(xué)習(xí)自定義控件開(kāi)發(fā)的例子,詳細(xì)代碼可以到下面進(jìn)行下載: 腳本之家下載地址
相關(guān)文章
VS2019下opencv4.1.2配置圖文教程(永久配置)
這篇文章主要介紹了VS2019下opencv4.1.2配置圖文教程,文中安裝步驟介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-11-11
SQL通用存儲(chǔ)過(guò)程分頁(yè),支持多表聯(lián)合
以前用.net寫(xiě)分頁(yè)存儲(chǔ)過(guò)程時(shí)老是一張表就要寫(xiě)一個(gè)procedure.很忙煩.后來(lái)有空就整合了一下,做了一個(gè)通用的sql分頁(yè)存儲(chǔ),支持多表聯(lián)合查詢分頁(yè).寫(xiě)的不好的地方,希望大鳥(niǎo)們多多指導(dǎo).使的查詢速度更快.2011-11-11
IE和火狐中模仿Click事件及提交到新窗口總結(jié)(asp.net)
在程序中去模擬一個(gè)click事件是可以的,如果這個(gè)click事件是來(lái)自<a>標(biāo)簽的,那如果希望得到單擊按鈕的效果,IE可以,但火狐無(wú)法實(shí)現(xiàn)2012-01-01
ASP.NET MVC5網(wǎng)站開(kāi)發(fā)用戶修改資料和密碼(六)
這篇文章主要介紹了ASP.NET MVC5網(wǎng)站開(kāi)發(fā)用戶修改資料和密碼,本文即將結(jié)束member區(qū)域的用戶部分,感興趣的小伙伴們可以參考一下2015-09-09
.NET Core系列之MemoryCache 緩存過(guò)期
這篇文章主要介紹了.NET Core系列之MemoryCache 緩存過(guò)期,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-08-08
ASP.NET實(shí)現(xiàn)根據(jù)IP獲取省市地址的方法
這篇文章主要介紹了ASP.NET實(shí)現(xiàn)根據(jù)IP獲取省市地址的方法,主要基于QQwry.dat純真IP數(shù)據(jù)庫(kù)來(lái)實(shí)現(xiàn)這一功能,非常實(shí)用,需要的朋友可以參考下2014-10-10
jQuery AJax調(diào)用asp.net webservers的實(shí)現(xiàn)代碼
代碼是轉(zhuǎn)載來(lái)的 本來(lái)今天寫(xiě)的 但是到現(xiàn)在還沒(méi)搞懂,慚愧啊2009-12-12
Remoting和Webservice的詳細(xì)介紹及區(qū)別
這篇文章主要介紹了Remoting和Webservice的詳細(xì)介紹及區(qū)別的相關(guān)資料,需要的朋友可以參考下2016-11-11

