本控件可以对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"%>
Copy code The code is as follows:
// ================================================== ====================
// Company name: Wildren Network Studio (http://www.wildren.com)
// Machine name: WWW-BBE63F97A80
// Registered organization name: Lenovo (Beijing) Limited
// CLR version: 2.0.50727.1433
// File name: Default.aspx.cs
// Creator: Shao Long
// Creation time: 2009-4- 4 16:29:49
// Program version: Version 1.0
// Function description: AspNetAjaxPager uses Demo
// Modification record:
//================== ================================================== ==
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
{
///When the paging navigation is clicked, the binding event is triggered by the control proxy object to redisplay the data
this.Pager1.OnPageIndexChanged = new PageIndexChangedDelegate(BindData);
}
}
///
/// Bind Repeater data
///
///
///
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();
///This part can be replaced by stored procedure paging, which will have no impact on the control.
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();
}
}
}
The above introduces www.xiaoxiaoshuo.net AspNetAjaxPager, AspNet's general non-refresh Ajax paging control, which supports multi-style and multi-data binding, including the content of www.xiaoxiaoshuo.net. I hope it will be helpful to friends who are interested in PHP tutorials.