One of the new controls introduced in ASP.NET 3.5 is the ListView control. It gives you the same flexibility as the
Repeater control, but with the features of the GridView and DetailsView, and then some! One of the niceties of this new control is that it uses the new
DataPager control, and that it lets you place this anywhere on your page, not just inside your ListView.
This new DataPager gives you a lot more control over its looks than what was available before. This control leaves all the rendering of the output to one of the
DataPagerField objects that you add to it, like so:
| ASP.NET |
1
2
3
4
5
6
7
8
9
|
<asp:DataPager runat="server" ID="pager" PageSize="10" >
<Fields>
<asp:NumericPagerField />
<asp:NextPreviousPagerField />
<asp:TemplatePagerField>
<PagerTemplate></PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>
|
ASP.NET 3.5 ships with three such pager fields: the NextPreviousPagerField, which displays buttons for the next or previous page, the
NumericPagerField, which displays a series of buttons for pages, and last but not least the
TemplatePagerField, which gives you fine control over the rendered output using a template. This, however, can lead to pretty complex markup in your ASPX page. You can, however, create your own custom DataPagerField, and it isn’t terribly difficult. In this article, I will explain you how.