asp.net Repeater之非常好的数据分页

2019-05-11 21:49:00于海丽


set { _AutoAjaxReturnPageUrl = value; }
}

/// <summary>
/// 无刷新调用的页面所返回的控件ID
/// </summary>
private string _AutoAjaxPageWebControl = "";

/// <summary>
/// 无刷新调用的页面所返回的控件ID
/// </summary>
[Bindable(false), Description("无刷新调用的页面所返回的控件ID")]
public string AutoAjaxPageWebControl
{
get { return _AutoAjaxPageWebControl; }

set { _AutoAjaxPageWebControl = value; }
}

/// <summary>
/// 输出html,在浏览器中显示控件
/// </summary>
/// <param name="output"> 要写出到的 HTML 编写器 </param>
protected override void Render(HtmlTextWriter output)
{
base.Render(output);

if (!this.Page.ClientScript.IsClientScriptBlockRegistered(this.Page.GetType(), "AjaxPageJs"))
{
output.Write("n<script type="text/javascript">var AjaxUrl='" + AutoAjaxReturnPageUrl + "';</script>");

output.Write("n<script type="text/javascript" src="" + this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "WebControlLibrary.Js.AjaxHelper.js") + ""></script>");

this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "AjaxPageJs", "");
}

#region 输出分页链接样式

string CssInfo = WebPageCss.CssStyle(Css, AlignSorts, this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "WebControlLibrary.img.bg_pager.png"));

output.WriteLine(CssInfo);

#endregion

#region 输出分页Js

output.WriteLine("<script language="JavaScript">n");

output.WriteLine(" function " + JsFunctionName + "(Obj,PageIndex)n");

output.WriteLine(" {n");

if (BoolIsAutoAjaxPage)
{
output.WriteLine(" AjaxHelper.Updater('" + AutoAjaxPageUrl.Replace("'", "").Replace(""", "") + "','" + AutoAjaxPageWebControl + "','" + System.Web.HttpContext.Current.Request.ServerVariables["QUERY_STRING"] + "&page=' + PageIndex + '');n");

}
else
{
output.WriteLine(" var getUrl="" + Url.Replace("'", "").Replace(""", "") + "&page=" + PageIndex + "";n");

output.WriteLine(" document.location.href=getUrl;n");
}

output.WriteLine(" }n");

output.WriteLine("</script>n");

#endregion

if (!DesignMode)
{
string Result = Pagination();

if (RecordCount > PageSize)
{
output.WriteLine(Result);
}
}
}

/// <summary>
/// 调用存储过程返回数据集
/// </summary>
/// <param name="IsProc">是否启用存储过程调用数据 true:启用</param>
/// <param name="PorcedureName">存储过程名</param>
/// <param name="TableName">表名</param>
/// <param name="TableCollName">表中该列来进行分页(必须是唯一性的字符,比如标识种子</param>
/// <param name="OrderBy">完整的排序字段值 不需要order by </param>