This is part of a larger project and perhaps in the future I will present the finished project, but for now this user control can help us organize our data with a data list.
- Create a new web site project in Visual Studio
- Add a new Web User control named Pager.
- In Source View (Asp.Net) write the following code
- <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Pager.ascx.cs" Inherits="UserControls_Pager" %><p>Page<asp:Label ID="currentPageLabel" runat="server" />of<asp:Label ID="howManyPagesLabel" runat="server" />
<asp:HyperLink ID="previousLink" runat="server">Previous</asp:HyperLink>
<asp:Repeater ID="pagesRepeater" runat="server"><ItemTemplate><asp:HyperLink ID="hyperlink" runat="server" Text='<%#Eval("Page") %>' NavigateUrl='<%#Eval("Url") %>' /></ItemTemplate></asp:Repeater><asp:HyperLink ID="nextLink" runat="server">Next</asp:HyperLink></p>