关于asp.net的分页,在网络有很多种分页,于是自己在找分页查询的时候,根本上分不清楚那个写的分页查询比较好,于是我根据网上的一些分页查询和自己原来写过的分页查询合并出来做了一个自己认为还可以的分页查询,当然我这里比较简单点,只有上一页和下一页,因为我做的是wap开发的因此比较简单,下面就是我写的代码:
DAO层代码:
/// <summary>
/// 分页获取内容数据信息
/// <param name="PageIndex">当前页码</param>
/// <paramname="pageSize">分页容量</param>
/// <paramname="strWhere">查询条件,若有条件限制则必须以where 开头</param>
/// <paramname="pageCount">传出参数:总页数统计</param>
/// <paramname="recordCount">传出参数:总记录统计</param>
/// </summary>
/// <returns>装载记录的IList</returns>
publicIList<News>GetAllNoteInfo(int PageIndex, int PageSize, out int PageCount, out int RecordCount, stringstrWhere,stringorderbystr)
{
try
{
stringstrSql = " SELECTN.nid,N.title,N.tid,N.source,N.keywords,N.author,N.createtime,N.updatetime,N.ischeck,N.ispost,N.totalpv,N.lasthpvFROM tb_News N ";
return DataCommonHelper<News>.GetDataFromDataTable(DataCommonHelper<News>.ExecutePager(PageIndex,PageSize, "nid","*", strSql, strWhere, orderbystr, out PageCount, outRecordCount, CONNSTR));
}
catch(Exception ex)
{
throw ex;
}
}
<