DataRow collection paging

This sample demonstrate how to create PagedList<T> collection manually.

Total Records:100, display 91 to 100
Order IDCustomer Name
91Customer_91
92Customer_92
93Customer_93
94Customer_94
95Customer_95
96Customer_96
97Customer_97
98Customer_98
99Customer_99
100Customer_100
<<  <  1  2  3  4  5  6  7  8  9  10  >  >>
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" 
Inherits="System.Web.Mvc.ViewPage<PagedList<DataRow>>" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc"%>
<%@ Import Namespace="System.Data"%>
 
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    DataRow collection paging
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 
<style type="text/css">
.pagerItem a{text-decoration:none}
.redbold{color:Red;font-weight:bold}
</style>
    <h2>DataRow collection paging</h2>
    <div>This sample demonstrate how to create PagedList&lt;T&gt; collection manually.</div><br />
<div>Total Records:<%=Model.TotalItemCount %>, display <%=Model.StartRecordIndex %> 
to <%=Model.EndRecordIndex %></div>
<table width="98%">
<tr><th>Order ID</th><th>Customer Name</th></tr>
<%foreach(DataRow dr in Model)
 {
     %>
     <tr><td><%=dr["id"] %></td><td><%=dr["CustomerName"] %></td></tr>
     <%
 } %>
</table>
 <%=Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", 
    CssClass = "pagerItem", FirstPageText = "<<", LastPageText = ">>", PrevPageText = "<", 
    NextPageText = ">", CurrentPagerItemWrapperFormatString = "<span class=\"redbold\">{0}</span>" })%>
</asp:Content>
        public ActionResult DataRowsPaging(int? id)
        {
            var dt = new DataTable("Orders");
            dt.Columns.Add(new DataColumn("Id", typeof(int)));
            dt.Columns.Add(new DataColumn("CustomerName", typeof(string)));
            for (int i = 1; i <= 100; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = i;
                dr[1] = "Customer_" + i;
                dt.Rows.Add(dr);
            }
            int pageSize = 10;
            int pageIndex = id ?? 1;
            PagedList<DataRow> pl = new PagedList<DataRow>(dt.Select(), pageIndex, pageSize);
            //or: PagedList<DataRow> pl =new PagedList<DataRow>(dt.Select("Id>"+(pageIndex-1)*pageSize+" and 
Id<="+pageIndex*pageSize), pageIndex, pageSize,dt.Rows.Count);
 
            return View(pl);
        }