【发布时间】:2013-07-19 20:08:43
【问题描述】:
我使用以下方法填充了一个 GridView:
List<MyObject> items = new List<MyObject>();
// here I am filling the list using SQL
PanelGridView.DataSource = items; //fill GridView with objects, this works when NOT using paging
PanelGridView.DataBind();
有了这个,并禁用了分页,我有一个完全填充的 GridView。但是,当我打开分页时,第一页被填满,但所有后续页面都是空的。我怎样才能确保所有项目都被考虑在内,并在页面之间正确划分(给定我指定的页面大小)?
编辑:我忘记包含此代码:
protected void PanelGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
PanelGridView.PageIndex = e.NewPageIndex;
PanelGridView.DataBind();
}
【问题讨论】:
-
您的面板对象是什么? “项目”已定义,但未定义面板。能否请您添加缺少的代码?
-
我更改了代码以避免混淆,并忘记将面板更改为项目。修复了代码。