• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

AspNetAjaxPager,Asp.Net通用无刷新Ajax分页控件,支持多样式多数据绑定_php技巧

php 搞代码 3年前 (2022-01-26) 20次浏览 已收录 0个评论

本控件可以对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" %> <BR><%@ Register Namespace="AspNetAjaxPager" TagPrefix="ajax" Assembly="AspNetAjaxPager"%> <BR> <BR><!---ecms -ecms -ecms  <BR>//====================================================================== <BR>// 公司名称: 野人网络工作室(http://www.wildren.com) <BR>// 机器名称: WWW-BBE63F97A80 <BR>// 注册组织名: Lenovo (Beijing) Limited <BR>// CLR版本: 2.0.50727.1433 <BR>// 文件名称: Default.aspx <BR>// 创建者: 邵龙 <BR>// 创建时间: 2009-4-4 16:29:49 <BR>// 程序版本: 1.0版 <BR>// 功能描述: AspNetAjaxPager使用Demo <BR>// 修改记录: <BR>//====================================================================== <BR>--> <BR> <BR> <BR><title>AspNetAjaxPager使用Demo</title> <BR><link href="css/style.css" type="text/css" rel="stylesheet" /> <BR><script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <BR> <BR><body> <BR> <BR><div> <BR><div id="pannel"> <BR><div class="PagingWrapper"> <BR> <BR> <BR><table border="0" cellpadding="0" cellspacing="0" class="stripe"> <BR><tr> <BR><td>编号</td> <BR><td>姓名</td> <BR><td>年龄</td> <BR></tr> <BR> <BR> <BR><tr> <BR><td> <BR><%# Eval("id")%> <BR></td> <BR><td> <BR><%# Eval("name") %> <BR></td> <BR><td> <BR><%# Eval("age")%> <BR></td> <BR></tr> <BR> <BR> <BR></table> <BR> <BR> <BR>



BackColor=”Transparent” BorderColor=”Red” BorderWidth=”0px” DescriptionText=”当前使用中:” GotoButtonValue=”转到”
CssClass=”navi” IsGotoSelectVisible=”False” IsGotoTextBoxVisible=”False” LeftPageSize=”0″ RightPageSize=”0″ CurrentNumberBgColor=”White” />





BackColor=”Transparent” BorderColor=”Red” BorderWidth=”0px” DescriptionText=”” GotoButtonValue=”转到本文来源gao@!dai!ma.com搞$$代^@码!网!搞gaodaima代码” CssClass=”navi”
RecordCount=”1500″ IsGotoSelectVisible=”False” IsGotoTextBoxVisible=”False”/>




BackColor=”Transparent” BorderColor=”Red” BorderWidth=”0px” DescriptionText=”” GotoButtonValue=”转到” CssClass=”navi”
RecordCount=”1500″ IsGotoSelectVisible=”False”/>




BackColor=”Transparent” BorderColor=”Red” BorderWidth=”0px” CssClass=”navi” DescriptionText=””
GotoButtonValue=”转到”
PagedControlID=”Repeater1″ RecordCount=”1500″ />




BackColor=”DarkGray” BorderColor=”Red” BorderWidth=”1px” CssClass=”navi” DescriptionText=””
GotoButtonValue=”转到” IsGotoSelectVisible=”False”
PagedControlID=”Repeater1″ RecordCount=”1500″ CellSpacing=”1px” />






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” />




BackColor=”Transparent” BorderColor=”Red” BorderWidth=”0px” CssClass=”navi” DescriptionText=””
GotoButtonValue=”转到” IsGotoSelectVisible=”False” IsGotoTextBoxVisible=”False”
PagedControlID=”Repeater1″ RecordCount=”1500″ CurrentNumberBgColor=”Yellow” CurrentPageColor=”Lime” LinkNumberWidth=”20px” />









<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文件内容:

//====================================================================== <BR>// 公司名称: 野人网络工作室(http://www.wildren.com) <BR>// 机器名称: WWW-BBE63F97A80 <BR>// 注册组织名: Lenovo (Beijing) Limited <BR>// CLR版本: 2.0.50727.1433 <BR>// 文件名称: Default.aspx.cs <BR>// 创建者: 邵龙 <BR>// 创建时间: 2009-4-4 16:29:49 <BR>// 程序版本: 1.0版 <BR>// 功能描述: AspNetAjaxPager使用Demo <BR>// 修改记录: <BR>//====================================================================== <BR>using System; <BR>using System.Data; <BR>using System.Configuration; <BR>using System.Web; <BR>using System.Web.Security; <BR>using System.Web.UI; <BR>using System.Web.UI.WebControls; <BR>using System.Web.UI.WebControls.WebParts; <BR>using System.Web.UI.HtmlControls; <BR>using System.Data.OleDb; <BR>using AspNetAjaxPager.Delegate; <BR>namespace Demo <BR>{ <BR>public partial class _Default : System.Web.UI.Page <BR>{ <BR>private OleDbConnection conn; <BR>private OleDbCommand cmd; <BR>protected void Page_Load(object sender, EventArgs e) <BR>{ <BR>if (!Page.IsPostBack) <BR>{ <BR>this.BindData(this.Pager1.CurrentPageIndex, this.Pager1.PageSize); <BR>} <BR>else <BR>{ <BR>///点击分页导航时由控件代理对象触发绑定事件重新显示数据 <BR>this.Pager1.OnPageIndexChanged = new PageIndexChangedDelegate(BindData); <BR>} <BR>} <BR>/// <summary> <BR>/// 绑定Repeater数据 <BR>/// </summary> <BR>///  <BR>///  <BR>public void BindData(int PageIndex, int PageSize) <BR>{ <BR>int intStartIndex = (PageIndex - 1) * PageSize + 1; <BR>int intEndIndex = PageIndex * PageSize; <BR>conn = new OleDbConnection(); <BR>conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/app_data/db.mdb"); <BR>cmd = conn.CreateCommand(); <BR>conn.Open(); <BR>///此部分可以换成存储过程分页,对控件没有任何影响 <BR>cmd.CommandText = "select count(*) from students"; <BR>int totalCount = (int)cmd.ExecuteScalar(); <BR>cmd.CommandText = string.Format("select * from students where id >= {0} and id <= {1}", intStartIndex, intEndIndex); <BR>DataSet ds = new DataSet(); <BR>OleDbDataAdapter da = new OleDbDataAdapter(cmd.CommandText, conn); <BR>da.Fill(ds); <BR>this.Pager1.RecordCount = totalCount; <BR>this.Repeater1.DataSource = ds; <BR>this.Repeater1.DataBind(); <BR>} <BR>} <BR>} <BR>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:AspNetAjaxPager,Asp.Net通用无刷新Ajax分页控件,支持多样式多数据绑定_php技巧
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址