Exemple #1
0
        /// <summary>
        /// 模拟数据库分页
        /// </summary>
        /// <returns></returns>
        private DataTable GetPagedDataTable()
        {
            whut.xljk.BLL.FileBLL bll = new whut.xljk.BLL.FileBLL();
            int pageIndex             = Grid1.PageIndex;
            int pageSize = Grid1.PageSize;

            string sortField     = Grid1.SortField;
            string sortDirection = Grid1.SortDirection;

            DataTable table2 = bll.GetAllList().Tables[0];
            DataView  view2  = table2.DefaultView;

            view2.Sort = String.Format("{0} {1}", sortField, sortDirection);

            DataTable table = view2.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);
        }
Exemple #2
0
 /// <summary>
 /// 返回总项数
 /// </summary>
 /// <returns></returns>
 private int GetTotalCount()
 {
     whut.xljk.BLL.FileBLL bll = new whut.xljk.BLL.FileBLL();
     bll.GetAllList();
     return(bll.GetAllList().Tables[0].Rows.Count);
 }