AspNetAjaxPager,Asp.Net通用無重新整理Ajax分頁控制項,支援多樣式多資料繫結_php技巧

來源:互聯網
上載者:User
本控制項可以對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="js/jquery-1.3.2.min.js" type="text/javascript"></script>
</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();
}
}
}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.