指引网

当前位置: 主页 > 编程开发 > C >

asp.net List数据源之 repeater分页

来源:网络 作者:佚名 点击: 时间:2017-07-19 23:04
[摘要] 

asp教程.net list数据源之 repeater分页
*/

/// <summary> 
  /// 根据当前页码,每页条数,取得相应数据。 
  /// </summary> 
  /// <param name="pagenum">每页显示条数</param> 
  /// <param name="currentpage">当前页码</param> 
  /// <returns></returns>
  public static list<message> getpagesdata(int pagenum, int currentpage)
  {
  list<message> list = new list<message>();
  stringbuilder sb = new stringbuilder();
  sb.append("select top " + pagenum + " * from zjagzm.message where ");
  sb.append("id not in (select top " + pagenum * currentpage + " id from zjagzm.message) order by uptime desc");
  datatable dt = dbhelpersql.getdataset(sb.tostring(), null);
  foreach (datarow row in dt.rows)
  {
  message ms = new message();
  ms.id = convert.toint32(row["id"]);
  ms.name = row["name"].tostring();
  ms.title = row["title"].tostring();
  ms.uptime = convert.todatetime(row["uptime"]);
  ms.contents = row["contents"].tostring();
  list.add(ms);
  }
  return list;

  } 

 

------分隔线----------------------------