/// <summary> /// 模拟数据库分页 /// </summary> /// <returns></returns> private DataTable GetPagedDataTable1() { Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department(); int pageIndex = Grid1.PageIndex; int pageSize = Grid1.PageSize; string sortField = Grid1.SortField; string sortDirection = Grid1.SortDirection; DataTable table3 = bll.GetList("").Tables[0]; DataView view3 = table3.DefaultView; view3.Sort = String.Format("{0} {1}", sortField, sortDirection); DataTable table = view3.ToTable(); DataTable paged = table.Clone(); int rowbegin = pageIndex * pageSize; int rowend = (pageIndex + 1) * pageSize; if (rowend > table.Rows.Count) { rowend = table.Rows.Count; } for (int i = rowbegin; i < rowend; i++) { paged.ImportRow(table.Rows[i]); } return(paged); }
/// <summary> /// 模拟数据库分页 /// </summary> /// <returns></returns> private DataTable GetPagedDataTable(int pageIndex, int pageSize) { Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department(); DataTable source = bll.GetList("").Tables[0]; 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); }
/// <summary> /// 模拟返回总项数 /// </summary> /// <returns></returns> private int GetTotalCount() { Demo.BLL.tb_JC_Department bll = new Demo.BLL.tb_JC_Department(); return(bll.GetList("").Tables[0].Rows.Count); }