C#基于数据库存储过程的AJAX分页实例

2019-12-26 12:06:16王旭

                    return dt;  
                }  
            }  
        }  
    }  
}

 

在DAL文件夹中( 层中) 创建一个Aticel.cs类  产生一个list

复制代码 using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Data;  
using LLSql.DAL;  
using WebApplication1.Model; 

 

namespace WebApplication1.DAL  
{  
    public class Aticel  
    {  
        public static List<Location> GetPageListByPageIndex(int pageSize,int currentpage,out int rowCount,out int pageCount)  
        {  
            DataTable dt= SqlHelper.ExecuteProcPageList(pageSize, currentpage,out rowCount,out pageCount);  
            var list = new List<Location>();// 声明一个泛型对象list  
            if (dt != null && dt.Rows.Count > 0)  
            {  
                //将DataTable转换成一个list  
                list = (from p in dt.AsEnumerable()  //(遍历DataTable)
                        select new Model.Location  
                        {  
                            Locid = p.Field<int>("locid"),   //将DateTable里的字段赋值给Location类中的属性  
                            LocName = p.Field<string>("locName"),