aspnetpaper分页

if (!IsPostBack)
{
try
{
this.AspNetPager_openlog.RecordCount = (int)bot.GetRecordCount("");//注意此处不要遗漏
BindData();
}
catch { }
}
-------------------------------------------------------------------------------------------------------------------------

protected void AspNetPager_PageChanged(object sender, EventArgs e)
{
BindData();
}

-------------------------------------------------------------------------------------------------------------------------

protected void BindData()
{
SqlConnection conn = new SqlConnection(PubConstant.ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from Openlog where Dormitory ='" + pname + "' order by Did desc", conn);
DataSet ds = new DataSet();
da.Fill(ds, AspNetPager_openlog.PageSize * (AspNetPager_openlog.CurrentPageIndex - 1), AspNetPager_openlog.PageSize, "temptbl");
DataTable dt = ds.Tables["temptbl"];
//绑定Repeater1数据源
rep_log.DataSource = dt;
rep_log.DataBind();
}

-------------------------------------------------------------------------------------------------------------------------

前台

<webdiyer:AspNetPager ID="AspNetPager_openlog" runat="server" Width="90%" UrlPaging ="false"
ShowPageIndexBox="Always" AlwaysShow="true" PageIndexBoxType="DropDownList" TextBeforePageIndexBox="转到: "
HorizontalAlign="Right" PageSize="8" OnPageChanged="AspNetPager_PageChanged" EnableTheming="true"
FirstPageText="首页" LastPageText="尾页" CssClass="paginator" NextPageText="下一页" PrevPageText="上一页">
</webdiyer:AspNetPager>

-------------------------------------------------------------------------------------------------------------------------

CSS

.paginator
{ clear:both;
font: 11px Arial, Helvetica, sans-serif;
padding: 0px 5px 0px 15px;
margin: 0px;
font-family:微软雅黑;
font-size:13px;
margin-bottom:10px;
}

/* 页面的背景以及字体*/
.paginator a
{
padding: 1px 6px;
border: solid 1px #7EC0EE;
background:url(../Images/System/pages.png);
text-decoration: none;
margin-right: 2px;
color:#436EEE;
}

.paginator a:visited
{
padding: 1px 6px;
border: solid 1px #99d6ff;
background: #fff;
text-decoration: none;
color:#4cb8ff;
}

.paginator .cpb
{
padding: 1px 6px;
font-weight: bold;
font-size: 13px;
border: none;
}

.paginator a:hover
{
color:#EE4000;
background: #ebf7ff;
border-color: #99d6ff;
text-decoration: none;
}

.paginator span
{
color: #4cb8ff;
}

posted on 2017-08-08 15:37  A欣  阅读(150)  评论(0编辑  收藏  举报

导航