1,引用AspNetPager.dll
2,<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
.aspx页面使用:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="fenyeok.aspx.cs" Inherits="fenyeok" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!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 id="Head1" runat="server">
<title>分页模板页,以后就用这个</title>
<style type="text/css">
a:Link{
font-size: 12px;
color: #3366cc;
text-decoration: none;
}
a:visited {
font-size: 12px;
color: #3366cc;
text-decoration: none;
}
.submitBtn {
background-image: url(submitfy.jpg);
font-size:12px;
height: 19px;
width: 37px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
}
</style>
</head>
<body style="font-size:12px;">
<form id="form1" runat="server">
<div>
分页模板页,以后就用这个,样式设置好
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Height="139px" Width="418px">
<Columns>
<asp:BoundField DataField="GoodID" HeaderText="GoodID" />
<asp:BoundField DataField="GoodName" HeaderText="GoodName" />
<asp:BoundField DataField="father" HeaderText="father" />
</Columns>
</asp:GridView> <br />
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="5" HorizontalAlign="Center" OnPageChanged="AspNetPager1_PageChanged"
ShowCustomInfoSection="Left" Width="95%" meta:resourceKey="AspNetPager1" Style="font-size: 12px"
CustomInfoHTML="共<b><font color= red >%RecordCount%</font></b>条记录 当前页:<font color= red ><b>%CurrentPageIndex%/%PageCount%</b></font> 每页:%PageSize%"
AlwaysShow="True" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" SubmitButtonText="确定" SubmitButtonClass="submitBtn"
CustomInfoStyle="FONT-SIZE: 12px" InputBoxStyle="width:30px; border:1px solid #999999; text-align:center; " TextBeforeInputBox="转到第" TextAfterInputBox="页 " >
</webdiyer:AspNetPager>
</div>
</form>
</body>
</html>
.aspx.cs 代码:
using Maticsoft.DBUtility;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ListBind();
}
}
private void ListBind()
{
string sqlstr = "select * from testgood ";
DataSet ds = DbHelperSQL.Query(sqlstr);
this.AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
//.net的自定义分页
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = ds.Tables[0].DefaultView;
GridView1.DataSource = pds;
GridView1.DataBind();
}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
ListBind();
}
AspNetPager的属性设置:
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" Width="100%" NumericButtonCount="6" UrlPaging="true" NumericButtonTextFormatString="[{0}]" CustomInfoHTML="第 <font color= red ><b>%CurrentPageIndex%</b></font> 页 共 %PageCount% 页 显示 %StartRecordIndex%-%EndRecordIndex% 条" ShowCustomInfoSection="left"
FirstPageText="首页
石家庄网站建设的优点:我们是专属定制,制作符合您公司业务、风格的网站,这就做到给您制作的网站是网络上独一无二的网站,这样更有利于搜索引擎的收录。如果您喜欢网络上某个风格的网站或者网站模板,我们是只仿制而不直接套用,我们会对其中的结构和样式做增减优化,做…
竞价排名营销是一种通过 竞价购买搜索引擎中关键词或关键短语的广告方式。竞价排名营销分为两种类型。 第一种,直接为真正的搜索引擎结果的排名付费,也就是说付的钱越多,网页所获得的排名名也就越高。 第二种则更类似于普通的广告。这种竞价排名营销方式通过…
网站优化对网站来说是非常重要的,直接决定和影响着网站所起到的作用,以及在各个地方当中的排名。在进行seo优化的过程中,我们必须要坚持一定的原则,真正的把这些事情做得更好,才可以确保最终的结果,这对于我们来说是非常重要的事。 SEO优化主要分为8小步: …