asp.net 无刷新分页实例代码

复制代码 代码如下:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Reflection;

namespace DAL
{
    public  class UserManageClass
    {
        /// <summary>
        /// 取得总页数
        /// </summary>
        /// <returns>总页数</returns>
        public int GetPageCount()
        {
            int counts;
            string SqlStr = "select count(0) from [User]";
            counts = new SQLHelper().Content(SqlStr, CommandType.Text);
            return counts;
        }
        /// <summary>
        /// 取出每一页的内容
        /// </summary>
        /// <param>开始页数</param>
        /// <param>结束页数</param>
        /// <returns>每一页的内容</returns>
        public DataTable GetPageDate(string SatrPage, string EndPage)
        {
            DataTable dt;
            string SqlStr = @"select * from
            (select *, ROW_NUMBER() over(order by id)as no_ from [User])aa
            where aa.no_ between '"+SatrPage+"' and '"+EndPage+"'";
            dt = new SQLHelper().ExecuteQuery(SqlStr, CommandType.Text);
            return dt;
        }

/// <summary>
        /// 将一个DataTable转换成列表
        /// </summary>
        /// <typeparam>实体对象的类型</typeparam>
        /// <param>要转换的DataTable</param>
        /// <returns></returns>
        public  List<T> DataTableToEntityList<T>(DataTable dt)
        {
            List<T> entiyList = new List<T>();

Type entityType = typeof(T);
            PropertyInfo[] entityProperties = entityType.GetProperties();

foreach (DataRow row in dt.Rows)
            {
                T entity = Activator.CreateInstance<T>();

foreach (PropertyInfo propInfo in entityProperties)
                {
                    if (dt.Columns.Contains(propInfo.Name))
                    {
                        if (!row.IsNull(propInfo.Name))
                        {
                            propInfo.SetValue(entity, row[propInfo.Name], null);
                        }
                    }
                }

entiyList.Add(entity);
            }

return entiyList;
        }


    }
}

PageService.ashx.cs一般处理程序代码:

复制代码 代码如下:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjgpxy.html