asp.net List數據源之 repeater分頁

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;

}

更多相關文章
一周排行