首页 新闻 会员 周边 捐助

linq+AspNetPager +Repeater分页问题

0
悬赏园豆:100 [已关闭问题]
代码
前台
//<reapeater>
//</reapeater>
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" CustomInfoHTML="共%PageCount%页%RecordCount%个数据,当前为第%CurrentPageIndex%页,每页%PageSize%条"
FirstPageText
="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页"
ShowBoxThreshold
="1" ShowCustomInfoSection="Right" Width="100%"
OnPageChanging
="AspNetPager1_PageChanged" PageSize="2">
</webdiyer:AspNetPager>

后台
protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
AspNetPager1.CurrentPageIndex
= 1;
BindUserList(
true);

}

}
/// <summary>
/// 绑定列表数据
/// </summary>r
protected void BindUserList(bool reloadRecordCount)
{
//BindControl bindC = new BindControl();
//bindC.BindBoundControl<Entities.Sys_User>(users.GetAllUsers().OrderBy(v => v.UID), this.rpt_list, 1);


if (reloadRecordCount)
{
AspNetPager1.RecordCount
= users.GetAllUsers().Count();
}
rpt_list.DataSource
= users.GetAllUsers().Skip((AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize).Take(AspNetPager1.PageSize);
rpt_list.DataBind();

}
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BindUserList(
false);
}

 问题主要是,页是可以分。但点击下一页,或是首页。数据显示很混乱,第一条数据一会在第一页,一会在最后一页

匆匆过客的主页 匆匆过客 | 初学一级 | 园豆:100
提问于:2010-07-22 12:37
< >
分享
其他回答(1)
0

在AspNetPager的PageChanging事件里需要指定AspNetPager的当前页:

 

protected void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex
= e.NewPageIndex;
LoadData();
}
~冻结~ | 园豆:39 (初学一级) | 2010-07-22 13:45
呵呵,分不多
支持(0) 反对(0) 匆匆过客 | 园豆:100 (初学一级) | 2010-07-22 13:53
@匆匆过客:呵呵,不少了。
支持(0) 反对(0) Astar | 园豆:40805 (高人七级) | 2010-07-22 14:26
0
  if (AspNetPager1.RecordCount == 0)
AspNetPager1.RecordCount =db.users.Count();

   var gaga= (from i in db.users
                          orderby i.InDate descending
                          select i).Skip(AspNetPager1.StartRecordIndex - 1).Take(AspNetPager1.PageSize); 
   AspNetPager1.DataSource = gaga;
   AspNetPager1.DataBind();
孤城意决 | 园豆:202 (菜鸟二级) | 2013-12-24 11:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册