asp.net Repeater之非常好的数据分页
2024-07-10 12:38:37
供稿:网友
分页控件源代码如下:
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
#region Assembly Resource Attribute
[assembly: System.Web.UI.WebResource("WebControlLibrary.Js.AjaxHelper.js", "text/javascript")]
[assembly: System.Web.UI.WebResource("WebControlLibrary.img.bg_pager.png", "image/gif")]
#endregion
namespace WebControlLibrary
{
/// <summary>
/// Repeater分页控件可进行Ajax分页(但Ajax分页不能传参数)
/// </summary>
[DefaultProperty("Text")]
[ToolboxData("<{0}:RepeaterPages runat=server></{0}:RepeaterPages>")]
public class RepeaterPages : WebControlLibrary.Repeater
{
// <summary>
/// 构造函数
/// </summary>
public RepeaterPages()
: base()
{
}
/// <summary>
/// 下一页分页文本内容
/// </summary>
private string _NextPage = ">";
/// <summary>
/// 下一页标记
/// </summary>
[Bindable(false), Description("下一页标记所显示的文本内容")]
public string NextPage
{
get { return _NextPage; }
set { _NextPage = value; }
}
/// <summary>
/// 下一页标记
/// </summary>
private string _LastPage = "<";
/// <summary>
/// 上一页标记
/// </summary>
[Bindable(false), Description("上一页标记所显示的文本内容")]
public string LastPage
{
get { return _LastPage; }
set { _LastPage = value; }
}
/// <summary>
/// 总记录数属性
/// </summary>
private int _RecordCount;
/// <summary>
/// 页面分页大小属性
/// </summary>
private int _PageSize;
/// <summary>
/// 当前页数
/// </summary>
private int _CurrentPage;
/// <summary>
/// 返回总页面
/// </summary>
private int _AllPages;
/// <summary>
/// 页面地址
/// </summary>
private string _Url;
/// <summary>
/// 传入Sql语句
/// </summary>
private string _SqlString;
/// <summary>
/// 每页显示页码数
/// </summary>
private int _PageNumberCount;
/// <summary>
/// 数据库中显示的字段列表
/// </summary>
private string _ShowTableCollName;
/// <summary>
/// 记录数属性
/// </summary>
[Bindable(true), Category("Appearance"), DefaultValue("0")]
private int RecordCount
{
get
{
int IntTempValue = 0;
if (Int32.TryParse(Sql_Function.SqlDb.RecordCounts(SqlString), out IntTempValue))
return IntTempValue;
else
return 0;
}
set
{
_RecordCount = value;
}
}
/// <summary>