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

AspNetPager分页控件的使用

2011-01-30 21:37 579 查看
protected void Page_Load(object sender, EventArgs e)
{
pager.RecordCount = bm.Count();
Bind();
}
private void Bind()
{
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = pager.PageSize;
pds.CurrentPageIndex = pager.CurrentPageIndex - 1;
pds.DataSource = bm.GetAll().Tables[0].DefaultView;

DataList1.DataSource = pds;
DataList1.DataBind();
}
protected void pager_PageChanged(object sender, EventArgs e)
{//分页事件,点击分页会改变CurrentPageIndex的值
Bind();
}

JYOnline分页控件在代码中:
1.

DataSet ds = bl.GetByQuery(strWhere, strOrder, AspNetPager1.CurrentPageIndex - 1, AspNetPager1.PageSize);
AspNetPager1.RecordCount = bllArticle.GetByQueryCount(strWhere);
2.protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindArticle();
}
3.web.config中<system.web>下添加节点
<pages>
<controls>
<add assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagPrefix="webdiyer"/>
<add tagPrefix="EZC" assembly="StudyEZ.Controls" namespace="StudyEZ.Controls"/>
</controls>
</pages>

AspNetPager分页控件的使用:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetAllExams();
}
}
private void GetAllExams()
{
PagedDataSource pds = new PagedDataSource();
DataSet ds=bllpaper.GetAllExam();
AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = ds.Tables[0].DefaultView;
this.RptExam.DataSource = pds;
this.RptExam.DataBind();
}
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
GetAllExams();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: