网格视图分页不起作用意味着它不会逐页显示记录
<data:EntityGridView ID="GridOpen" runat="server" AutoGenerateColumns="false" AllowMultiColumnSorting="false"
DefaultSortDirection="Ascending" AllowPaging="false" PageSize="10" OnPageIndexChanging="GridOpen_PageIndexChanging"
OnSelectedIndexChanged="GridOpen_SelectedIndexChanged" DataKeyNames="OrderNo" Width="100%"
OnRowDataBound="GridOpen_OnRowDataBound" ExcelExportFileName="Export_AccountTerms.xls">
<Columns>
<asp:BoundField DataField="OrderNo" HeaderText="Order No" SortExpression="[OrderNo]" />
</Columns>
这是我的数据源并绑定网格
_actOpen = _actOrdServices.GetPaged("StatusID=1 AND AssignedDispatchBoardID = " + DispatchBoard + " AND CompanyId=" + Session["CompanyId"].ToString(), "OrderNo Desc", GridOpen.PageIndex, GridOpen.PageSize, out count);
GridOpen.DataSource = _actOpen;
我也尝试过分页
GridOpen.AllowPaging = true;
我的商店程序运行正常,但我不知道这不是网格中的显示分页
任何指南都会深表欢迎。
答案 0 :(得分:1)
首先在您的aspx代码中,AllowPaging =“false”使其成为“true”。
然后在PageIndexChanging事件后面的代码中执行此操作,
protected void GridOpen_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridOpen.DataSource = _actOpen;
GridOpen.PageIndex = e.NewPageIndex;
GridOpen.DataBind();
}
答案 1 :(得分:0)
gridview的allow paging属性设置为false (AllowPaging = “假”) 把它变成真实并再次检查。
答案 2 :(得分:0)
除了你必须完成的工作之外,还需要在aspx.cs中编写分页事件:
1)确保你已经完成,在aspx页面中允许paging =“true”(在gridview中)
2)然后在代码中注册事件:
protected void GridOpen_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridOpen.DataSource = YourOBJ.Method_yourmethod();
GridOpen.PageIndex = e.NewPageIndex;
GridOpen.DataBind();
}