FineUI 官方论坛
标题:
f:Grid OnPageIndexChange监听方法
[打印本页]
作者:
马焕平
时间:
2016-12-29 18:04
标题:
f:Grid OnPageIndexChange监听方法
这是表格的设置信息
<f:Grid ID="Grid2" Title="表格" EnableCollapse="true" PageSize="5" ShowBorder="true" ShowHeader="true" IsDatabasePaging="true" AllowPaging="true" ShowPagingMessage="true"
runat="server" EnableCheckBoxSelect="false" Width="1000px" Height="300" DataKeyNames="ID,city,county,street,village,reporter,reportUnit,operType,operTime,checked,remark"
EnableRowDoubleClickEvent="true" >
在OnPageIndexChange对应的AddressReportGrid_PageIndexChange方法里面的Grid2.pageIndex 一直为0,我是按照在线的代码的思路设计的。
主要的方法几乎没改动
public void AddressReportGrid_PageIndexChange(object sender, EventArgs e)
{
Alert.Show(Grid2.PageIndex.ToString());
AddressReportGridBind();
}
public void AddressReportGridBind()
{
Grid2.RecordCount = reportTable.Rows.Count;
DataTable table = GetReportGridPagedDataTable(Grid2.PageIndex, Grid2.PageSize);
//绑定到Grid
Grid2.DataSource = table;
Grid2.DataBind();
}
public DataTable GetReportGridPagedDataTable(int pageIndex, int pageSize)
{
DataTable source = reportTable;
DataTable paged = source.Clone();
int rowbegin = pageIndex * pageSize;
int rowend = (pageIndex + 1) * pageSize;
if (rowend > source.Rows.Count)
{
rowend = source.Rows.Count;
}
for (int i = rowbegin; i < rowend; i++)
{
paged.ImportRow(source.Rows[i]);
}
return paged;
}
作者:
马焕平
时间:
2016-12-30 09:52
自己结贴,pageIndex属性不能随着控件的改变而改变,源码中有//Grid1.PageIndex = e.NewPageIndex;
的注释,我们要把事件得到的新pageindex赋值给Gird的pageIndex,这样分页就能正常实现了
欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/)
Powered by Discuz! X3.4