以下文章只是本人学习过程中的一个总结哈!
1 首先,我们需要将AspNetPager.dll和AspNetPager.xml这两个文件放到bin目录中。
2,在索要使用的aspx文件中添加下面这段代码
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
3,在body里面
<div style="padding-left:450px; margin-top:20px;">
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="true"
CssClass="Pages" CurrentPageButtonClass="cpb" FirstPageText="首页"
HorizontalAlign="Center" LastPageText="尾页" NextPageText="后页"
OnPageChanging="AspNetPager1_PageChanging" PrevPageText="前页">
</webdiyer:AspNetPager>
</div>
其中相应的css
<style type="text/css">
.Pages{ color:#999;}
.Pages a, .pages.cpb{ text-decoration:none; float:left; padding: 0 5px; border:1px solid #ddd; background:#ffff; margin:0 2px; font-size:11px; color:#00 0;}
.Pages a:hover { background-color: #E61636; color:#fff;border:1px solid #E61636; text-decoration:none;}
.Pages .cpb { font-weight: bold; color: #fff; background: #E61636; border:1px solid #E61636;}
</style>
4.aspx.cs后台代码
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
binddata();
}
public void binddata()
{
BLLadmin blladmin = new BLLadmin();
DataSet ds = blladmin.adminlist(AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "info");
GridView1.DataSource = ds;
GridView1.DataBind();
}
在这个过程中可能出现在不到命名空间,原因是UI层中没用引用bin文件夹中的AspNetPager.dll