日期:2014-05-17  浏览次数:20427 次

AspNetPager翻页但无数据显示
求助啊!
用的AspNetPager翻页,设定每10条一页,输入了11条记录,能正确分2也,第一页也正确显示了10条记录,但一旦翻到第二页就显示无数据,搞了2天了!哭死~
代码如下:
ds = manage.GetNewsListByName(_channelName,_parentName);
        Response.Write("<script>alert('"+ds.Tables[0].Rows.Count.ToString()+"');</script>");
        AspNetPager1.RecordCount = ds.Tables[0].Rows.Count;
        AspNetPager1.PageSize = 10;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables[0].DefaultView;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex-1;
        pds.PageSize = AspNetPager1.PageSize;
        GvList.DataSource = pds;
        GvList.DataBind();
        if (ds.Tables[0].Rows.Count > 0)
        {
            AspNetPager1.Visible = true;
        }
        else
        {
            AspNetPager1.Visible = false;
        }

用js弹了下,第一页正确弹出11,第二页为0
sql肯定没问题,不然也不会弹出11,请问如何解决,十分感谢!

------解决方案--------------------
翻页事件中重新绑定。
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
this.PageFen();//重新绑定
}
------解决方案--------------------
对啊  你分页的话有个事件

protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
//绑定数据
}

   我做的贴出来  你参考下

        //绑定数据