国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

一個比較通用的分頁控件,完整的設(shè)計時支持和比較流行的分頁模式(提供源碼下載)

2024-07-10 13:25:14
字體:
供稿:網(wǎng)友

這是我寫的一個分頁控件,功能如下:

1.支持設(shè)計時支持和兩種分頁模式,其中綜合分頁模式的效果如下:

一個比較通用的分頁控件,完整的設(shè)計時支持和比較流行的分頁模式(提供源碼下載)

普通分頁模式的效果如下:

一個比較通用的分頁控件,完整的設(shè)計時支持和比較流行的分頁模式(提供源碼下載)

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

一個比較通用的分頁控件,完整的設(shè)計時支持和比較流行的分頁模式(提供源碼下載)

 

一個比較通用的分頁控件,完整的設(shè)計時支持和比較流行的分頁模式(提供源碼下載)

一個比較通用的分頁控件,完整的設(shè)計時支持和比較流行的分頁模式(提供源碼下載)

使用方法:

在aspx頁面中:

復(fù)制代碼 代碼如下:


<%@ 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" href="style/comm.css" />
</head>
<body>
<form runat="server">
<div>
  
<asp:GridView runat="server" AllowPaging="false" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" PagerSettings-Visible="false"
Width="80%" 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="序號">
<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 runat="server" ButtonText="GO" EndPageText="末頁"
FirstPageText="首頁" NextPageText="下一頁" PageSize="15" PrePageText="上一頁" OnPageChanged="Page_Changed" PageMode=Normal BackColor="#FFE0C0" BorderColor="#FFC0C0" BorderStyle="Solid" BorderWidth="1px" ForeColor="#804040">
<ButtonStyle CssClass="btn1_mouseout" />
<TextBoxStyle CssClass="blue_rounded"/>
<LabelStyle ForeColor="Red" Font-Bold="True" />
</Cyclone:AspNetPager>
  
</div>
</form>
</body>
</html>


在后臺代碼中:

復(fù)制代碼 代碼如下:


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)前頁碼查詢需要的數(shù)據(jù)
/// </summary>
/// <param>頁碼</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; }
}
}


另外:

本分頁控件還包含簡單屬性,復(fù)雜屬性,自定義視圖狀態(tài),分頁事件,創(chuàng)建控件,render控件,Attribute,設(shè)計時支持等比較齊全的自定義控件的元素,是個不錯學(xué)習(xí)自定義控件開發(fā)的例子,詳細(xì)代碼可以到下面進行下載: 腳本之家下載地址

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 瑞安市| 德兴市| 永福县| 应用必备| 牙克石市| 平昌县| 阿拉尔市| 历史| 平乐县| 调兵山市| 神池县| 武夷山市| 民乐县| 秦皇岛市| 瑞金市| 仙居县| 长岭县| 闽侯县| 化州市| 东至县| 饶阳县| 山阳县| 中牟县| 昂仁县| 福建省| 正蓝旗| 宁国市| 晋江市| 亚东县| 宜川县| 玉龙| 贵德县| 彭水| 灵台县| 武威市| 怀集县| 平罗县| 栾城县| 嘉善县| 乌兰浩特市| 曲水县|