﻿# Repeater, DataList 等資料控制項要怎麼實做分頁

使用 GridView 做一個簡單網頁版型套版實在是太浪費了，通常一個簡單的 List 我們會直接用 Repeater 就解決了，但是當需要做到分頁功能時，可能就變的不太好做。

在 CodeProject 網站上[有篇文章](http://www.codeproject.com/KB/custom-controls/CollectionPager.aspx "Pager Control for Repeater, DataList, or an Enumerable Collection")(含原始碼)實做了一個分頁的控制項，可以直接跟 Repeater, DataList 控制項做搭配，還蠻實用的，可以下載回來試試看。

> **Pager Control for Repeater, DataList, or an Enumerable Collection  
> **[http://www.codeproject.com/KB/custom-controls/CollectionPager.aspx](http://www.codeproject.com/KB/custom-controls/CollectionPager.aspx)

另外在 ASP.NET 3.5 有出新的 ListView 控制項與 DataPager 控制項，架構更清楚且彈性，有空的人可以研究一下。

以下是相關連結：

-   Using ASP.NET 3.5's ListView and DataPager Controls - Displaying Data with the ListView  
    http://aspnet.4guysfromrolla.com/articles/122607-1.aspx
    
-   Using ASP.NET 3.5's ListView and DataPager Controls - Grouping Data with the ListView:  
    [https://weblogs.asp.net/scottgu/jan-4th-links-asp-net-asp-net-ajax-asp-net-mvc-visual-studio-iis7](https://weblogs.asp.net/scottgu/jan-4th-links-asp-net-asp-net-ajax-asp-net-mvc-visual-studio-iis7)
    
-   ListView and DataPager in ASP.NET 3.5  
    [https://web.archive.org/web/20130918021751/http://www.west-wind.com:80/WebLog/posts/127340.aspx](https://web.archive.org/web/20130918021751/http://www.west-wind.com:80/WebLog/posts/127340.aspx)
    
-   DataPager Class  
    [http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datapager.aspx](http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datapager.aspx)
