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

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

/// <returns></returns>
public static bool isNumber(string s)
{
int Flag = 0;
char[] str = s.ToCharArray();
for (int i = 0; i < str.Length; i++)
{
if (Char.IsNumber(str[i]))
{
Flag++;
}
else
{
Flag = -1;
break;
}
}
if (Flag > 0)
{
return false;
}
else
{
return true;
}
}

}
}


前台页面样例:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="FrameWork.Web.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Repeater数据分页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a {
font-size: 12px;
color: #000000;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: underline;
color: #4455aa;
}
a:active {
text-decoration: none;
color: #000000;
}
-->
</style>
</head>
<body>
<br>
<br>
<br>
<WebControl:RepeaterPages ID="RepeaterPages1" runat="server" AutoPageConcise="True" Css="Msn Gray Style" PageSize="15" SelectPage="False">
<HeaderTemplate>
<div style="line-height:200%;width:700px;margin:0 auto;">
<ul>
</HeaderTemplate>
<ItemTemplate>
<li style="list-style:none;">·<a href="javascript:"><%#Eval("Sys_NewsList_Title")%></a></li>
</ItemTemplate>
<FooterTemplate>
</ul>
</div>
</FooterTemplate>
</WebControl:RepeaterPages>
</body>
</html>

后台代码:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;

namespace FrameWork.Web
{
public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}

protected void Bind()
{
string Sql = "select count(Sys_NewsList_ID) from Sys_NewsList";//查询Sql语句

#region 列表选项

#region 分页控件基本属性

RepeaterPages1.SqlString = Sql;//用于统计总记录数和进行数据分页的Sql语句

RepeaterPages1.LastPage = "< Prev";