<asp:ListView ID="livComments" runat="server" DataSourceID="CommentsObjectDataSource" EnableViewState="False" onitemcommand="livComments_ItemCommand" >
<ItemTemplate>
... /template here/ ...
</ItemTemplate>
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
<asp:DataPager ID="CommentDataPager" runat="server" PageSize="5">
<Fields>
<asp:TemplatePagerField OnPagerCommand="TemplatePagerField_OnPagerCommand">
<PagerTemplate>
<asp:Button ID="FirstButton" runat="server" CssClass="first" CommandName="First" Text="First" Enabled='<%# Container.StartRowIndex > 0 %>' />
<asp:Button ID="PreviousButton" runat="server" CommandName="Previous" Text='<%# (Container.StartRowIndex - Container.PageSize + 1).ToString() + " - " + (Container.StartRowIndex).ToString() %>' Visible='<%# Container.StartRowIndex > 0 %>' />
<!--<asp:Label ID="CurrentPageLabel" runat="server" Text='<%# (Container.StartRowIndex + 1).ToString() + "-" + ((Container.StartRowIndex + Container.PageSize > Container.TotalRowCount) ? (Container.TotalRowCount) : (Container.StartRowIndex + Container.PageSize)).ToString() %>' />-->
<asp:Button ID="NextButton" runat="server" CommandName="Next" Text='<%# (Container.StartRowIndex + Container.PageSize + 1).ToString() + " - " + ((Container.StartRowIndex + Container.PageSize*2 > Container.TotalRowCount) ? (Container.TotalRowCount) : (Container.StartRowIndex + Container.PageSize*2)).ToString() %>' Visible='<%# (Container.StartRowIndex + Container.PageSize) < Container.TotalRowCount %>' />
<asp:Button ID="LastButton" runat="server" CssClass="last" CommandName="Last" Text='Last' Enabled='<%# Container.StartRowIndex < (Container.TotalRowCount - Container.PageSize) %>'/>
</PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>
</LayoutTemplate>
</asp:ListView>
You’ll get something like this:
