本控件可以对GridView,Repeater,DataGrid,DataList...几乎所有的.net数据绑定控件进行分页,全部无刷新,数据绑定部分可以使用存储过程也可以直接使用sql语句,这对本控件没有任何干扰!本控件具有较好的用户界面,能够根据需要变换各种样式,配合css控制效果则更好!
1.分页样式效果图:
2.如何使用:
于bin目录下添加:AspNetAjaxPager.dll引用
aspx文件内容:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Demo._Default" %>
<%@ Register Namespace="AspNetAjaxPager" TagPrefix="ajax" Assembly="AspNetAjaxPager"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
//======================================================================
// 公司名称: 野人网络工作室(http://www.wildren.com)
// 机器名称: WWW-BBE63F97A80
// 注册组织名: Lenovo (Beijing) Limited
// CLR版本: 2.0.50727.1433
// 文件名称: Default.aspx
// 创建者: 邵龙
// 创建时间: 2009-4-4 16:29:49
// 程序版本: 1.0版
// 功能描述: AspNetAjaxPager使用Demo
// 修改记录:
//======================================================================
-->
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>AspNetAjaxPager使用Demo</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<script src="/UploadFiles/2021-04-02/jquery-1.3.2.min.js"></head>
<body>
<form id="form1" runat="server">
<div>
<div id="pannel">
<div class="PagingWrapper">
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" class="stripe">
<tr>
<td>编号</td>
<td>姓名</td>
<td>年龄</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("id")%>
</td>
<td>
<%# Eval("name") %>
</td>
<td>
<%# Eval("age")%>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
<div>
<ajax:AjaxPager ID="Pager1" runat="server" AjaxContainerID="pannel" PagedControlID="Repeater1" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" DescriptionText="当前使用中:" GotoButtonValue="转到"
CssClass="navi" IsGotoSelectVisible="False" IsGotoTextBoxVisible="False" LeftPageSize="0" RightPageSize="0" CurrentNumberBgColor="White" />
<br />
<br />
</div>
<ajax:AjaxPager ID="AjaxPager1" runat="server" AjaxContainerID="pannel" PagedControlID="Repeater1" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" DescriptionText="" GotoButtonValue="转到" CssClass="navi"
RecordCount="1500" IsGotoSelectVisible="False" IsGotoTextBoxVisible="False"/>
<br />
<br />
<ajax:AjaxPager ID="AjaxPager2" runat="server" AjaxContainerID="pannel" PagedControlID="Repeater1" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" DescriptionText="" GotoButtonValue="转到" CssClass="navi"
RecordCount="1500" IsGotoSelectVisible="False"/>
<br />
<br />
<ajax:AjaxPager ID="AjaxPager3" runat="server" AjaxContainerID="pannel" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" CssClass="navi" DescriptionText=""
GotoButtonValue="转到"
PagedControlID="Repeater1" RecordCount="1500" />
<br />
<br />
<ajax:AjaxPager ID="AjaxPager4" runat="server" AjaxContainerID="pannel" Align="left"
BackColor="DarkGray" BorderColor="Red" BorderWidth="1px" CssClass="navi" DescriptionText=""
GotoButtonValue="转到" IsGotoSelectVisible="False"
PagedControlID="Repeater1" RecordCount="1500" CellSpacing="1px" />
<br />
<br />
<br />
<ajax:AjaxPager ID="AjaxPager5" runat="server" AjaxContainerID="pannel" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" CssClass="navi" DescriptionText=""
GotoButtonValue="转到" IsGotoTextBoxVisible="False"
PagedControlID="Repeater1" RecordCount="1500" LinkIsText="False" NextLink="img/next.gif" FirstLink="img/first.gif" LastLink="img/last.gif" PreviousLink="img/previous.gif" />
<br />
<br />
<ajax:AjaxPager ID="AjaxPager6" runat="server" AjaxContainerID="pannel" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" CssClass="navi" DescriptionText=""
GotoButtonValue="转到" IsGotoSelectVisible="False" IsGotoTextBoxVisible="False"
PagedControlID="Repeater1" RecordCount="1500" CurrentNumberBgColor="Yellow" CurrentPageColor="Lime" LinkNumberWidth="20px" />
<br />
<br />
</div>
</div>
</form>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
$(".stripe tr").mouseover(function(){
$(this).addClass("over");}).mouseout(function(){
$(this).removeClass("over");})
$(".stripe tr:even").addClass("alt");
});
</script>
.cs文件内容:
复制代码 代码如下:
//======================================================================
// 公司名称: 野人网络工作室(http://www.wildren.com)
// 机器名称: WWW-BBE63F97A80
// 注册组织名: Lenovo (Beijing) Limited
// CLR版本: 2.0.50727.1433
// 文件名称: Default.aspx.cs
// 创建者: 邵龙
// 创建时间: 2009-4-4 16:29:49
// 程序版本: 1.0版
// 功能描述: AspNetAjaxPager使用Demo
// 修改记录:
//======================================================================
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using AspNetAjaxPager.Delegate;
namespace Demo
{
public partial class _Default : System.Web.UI.Page
{
private OleDbConnection conn;
private OleDbCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.BindData(this.Pager1.CurrentPageIndex, this.Pager1.PageSize);
}
else
{
///点击分页导航时由控件代理对象触发绑定事件重新显示数据
this.Pager1.OnPageIndexChanged = new PageIndexChangedDelegate(BindData);
}
}
/// <summary>
/// 绑定Repeater数据
/// </summary>
/// <param name="PageIndex"></param>
/// <param name="PageSize"></param>
public void BindData(int PageIndex, int PageSize)
{
int intStartIndex = (PageIndex - 1) * PageSize + 1;
int intEndIndex = PageIndex * PageSize;
conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/app_data/db.mdb");
cmd = conn.CreateCommand();
conn.Open();
///此部分可以换成存储过程分页,对控件没有任何影响
cmd.CommandText = "select count(*) from students";
int totalCount = (int)cmd.ExecuteScalar();
cmd.CommandText = string.Format("select * from students where id >= {0} and id <= {1}", intStartIndex, intEndIndex);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd.CommandText, conn);
da.Fill(ds);
this.Pager1.RecordCount = totalCount;
this.Repeater1.DataSource = ds;
this.Repeater1.DataBind();
}
}
}
1.分页样式效果图:
2.如何使用:
于bin目录下添加:AspNetAjaxPager.dll引用
aspx文件内容:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Demo._Default" %>
<%@ Register Namespace="AspNetAjaxPager" TagPrefix="ajax" Assembly="AspNetAjaxPager"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
//======================================================================
// 公司名称: 野人网络工作室(http://www.wildren.com)
// 机器名称: WWW-BBE63F97A80
// 注册组织名: Lenovo (Beijing) Limited
// CLR版本: 2.0.50727.1433
// 文件名称: Default.aspx
// 创建者: 邵龙
// 创建时间: 2009-4-4 16:29:49
// 程序版本: 1.0版
// 功能描述: AspNetAjaxPager使用Demo
// 修改记录:
//======================================================================
-->
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>AspNetAjaxPager使用Demo</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<script src="/UploadFiles/2021-04-02/jquery-1.3.2.min.js"></head>
<body>
<form id="form1" runat="server">
<div>
<div id="pannel">
<div class="PagingWrapper">
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" class="stripe">
<tr>
<td>编号</td>
<td>姓名</td>
<td>年龄</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("id")%>
</td>
<td>
<%# Eval("name") %>
</td>
<td>
<%# Eval("age")%>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
<div>
<ajax:AjaxPager ID="Pager1" runat="server" AjaxContainerID="pannel" PagedControlID="Repeater1" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" DescriptionText="当前使用中:" GotoButtonValue="转到"
CssClass="navi" IsGotoSelectVisible="False" IsGotoTextBoxVisible="False" LeftPageSize="0" RightPageSize="0" CurrentNumberBgColor="White" />
<br />
<br />
</div>
<ajax:AjaxPager ID="AjaxPager1" runat="server" AjaxContainerID="pannel" PagedControlID="Repeater1" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" DescriptionText="" GotoButtonValue="转到" CssClass="navi"
RecordCount="1500" IsGotoSelectVisible="False" IsGotoTextBoxVisible="False"/>
<br />
<br />
<ajax:AjaxPager ID="AjaxPager2" runat="server" AjaxContainerID="pannel" PagedControlID="Repeater1" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" DescriptionText="" GotoButtonValue="转到" CssClass="navi"
RecordCount="1500" IsGotoSelectVisible="False"/>
<br />
<br />
<ajax:AjaxPager ID="AjaxPager3" runat="server" AjaxContainerID="pannel" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" CssClass="navi" DescriptionText=""
GotoButtonValue="转到"
PagedControlID="Repeater1" RecordCount="1500" />
<br />
<br />
<ajax:AjaxPager ID="AjaxPager4" runat="server" AjaxContainerID="pannel" Align="left"
BackColor="DarkGray" BorderColor="Red" BorderWidth="1px" CssClass="navi" DescriptionText=""
GotoButtonValue="转到" IsGotoSelectVisible="False"
PagedControlID="Repeater1" RecordCount="1500" CellSpacing="1px" />
<br />
<br />
<br />
<ajax:AjaxPager ID="AjaxPager5" runat="server" AjaxContainerID="pannel" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" CssClass="navi" DescriptionText=""
GotoButtonValue="转到" IsGotoTextBoxVisible="False"
PagedControlID="Repeater1" RecordCount="1500" LinkIsText="False" NextLink="img/next.gif" FirstLink="img/first.gif" LastLink="img/last.gif" PreviousLink="img/previous.gif" />
<br />
<br />
<ajax:AjaxPager ID="AjaxPager6" runat="server" AjaxContainerID="pannel" Align="left"
BackColor="Transparent" BorderColor="Red" BorderWidth="0px" CssClass="navi" DescriptionText=""
GotoButtonValue="转到" IsGotoSelectVisible="False" IsGotoTextBoxVisible="False"
PagedControlID="Repeater1" RecordCount="1500" CurrentNumberBgColor="Yellow" CurrentPageColor="Lime" LinkNumberWidth="20px" />
<br />
<br />
</div>
</div>
</form>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
$(".stripe tr").mouseover(function(){
$(this).addClass("over");}).mouseout(function(){
$(this).removeClass("over");})
$(".stripe tr:even").addClass("alt");
});
</script>
.cs文件内容:
复制代码 代码如下:
//======================================================================
// 公司名称: 野人网络工作室(http://www.wildren.com)
// 机器名称: WWW-BBE63F97A80
// 注册组织名: Lenovo (Beijing) Limited
// CLR版本: 2.0.50727.1433
// 文件名称: Default.aspx.cs
// 创建者: 邵龙
// 创建时间: 2009-4-4 16:29:49
// 程序版本: 1.0版
// 功能描述: AspNetAjaxPager使用Demo
// 修改记录:
//======================================================================
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using AspNetAjaxPager.Delegate;
namespace Demo
{
public partial class _Default : System.Web.UI.Page
{
private OleDbConnection conn;
private OleDbCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.BindData(this.Pager1.CurrentPageIndex, this.Pager1.PageSize);
}
else
{
///点击分页导航时由控件代理对象触发绑定事件重新显示数据
this.Pager1.OnPageIndexChanged = new PageIndexChangedDelegate(BindData);
}
}
/// <summary>
/// 绑定Repeater数据
/// </summary>
/// <param name="PageIndex"></param>
/// <param name="PageSize"></param>
public void BindData(int PageIndex, int PageSize)
{
int intStartIndex = (PageIndex - 1) * PageSize + 1;
int intEndIndex = PageIndex * PageSize;
conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/app_data/db.mdb");
cmd = conn.CreateCommand();
conn.Open();
///此部分可以换成存储过程分页,对控件没有任何影响
cmd.CommandText = "select count(*) from students";
int totalCount = (int)cmd.ExecuteScalar();
cmd.CommandText = string.Format("select * from students where id >= {0} and id <= {1}", intStartIndex, intEndIndex);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd.CommandText, conn);
da.Fill(ds);
this.Pager1.RecordCount = totalCount;
this.Repeater1.DataSource = ds;
this.Repeater1.DataBind();
}
}
}
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
更新日志
2024年11月29日
2024年11月29日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]