您的位置:首页 > 编程语言 > ASP

简单实用的分页控件 AspNetPager.dll 的使用方法

2010-05-18 18:22 766 查看
前台页面的代码:

  <webdiyer:AspNetPager Width="99%" urlpaging="true" urlpageindexname="page"
id="anp" morebuttontype="Text"
numericbuttontype="Text" pagingbuttontype="Image" pagesize="10" imagepath="http://www.cnblogs.com/Images/Page/"
alwaysshow="false" runat="server" showinputbox="Always" inputboxclass="Page_TextBox"
submitbuttonclass="" submitbuttontext="GO" textafterinputbox=" " horizontalalign="Right"
showcustominfosection="Left" custominfohtml="总记录数:0 总页数:0"
onpagechanged="anp_PageChanged" >
</webdiyer:AspNetPager>

后台代码:

protected void Pager1_PageChanged(object sender, EventArgs e)
{
OracleConnection objcon = this.getcon();
string querystr = "select * from stu";
OracleDataAdapter da = new OracleDataAdapter(querystr, objcon);
DataSet ds = new DataSet();
da.Fill(ds, "stu");
this.GridView1.DataSource = this.getPage(ds); /***主要的步骤在这里,调用下面的方法***/
this.GridView1.DataBind();
} public PagedDataSource getPage(DataSet ds)
{
this.Pager1.RecordCount = ds.Tables[0].Rows.Count;
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.CurrentPageIndex = Pager1.CurrentPageIndex - 1;
pds.PageSize = Pager1.PageSize;
return pds;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: