ASP.NET 3.5 DataPager Control ASP.NET 3.5 introduces a new control named as DataPager. It provides users to create interfaces for navigation through multiple pages containing multiple records within it. DataPager control can work with any control that supports IPageableItemContainer interface. In ASP.NET 3.5 ListView is one and the only control that supports this interface. The DataPager control is having some build in properties: PagedControlID: It is used to get or set the control to page. If the DataPager is inside the ListView, if you don’t mention the PagedControlId it will take the ListView as the control to page. If your DataPager is outside of the ListView then you have to mention the PagedControlId to the id of the ListView. PageSize: It is used to get or set the number of data items to display in a page. StartRowIndex: It is used to get the index of the first item in a page. MaximumRow: You can use it to get the maximum number of rows to retrieve from the database for a page. TotalRowCount(read only): To get the total number of rows or items available in the datasource . Example: <asp:DataPager ID = “pager” runat = “server” PageSize = “10”> </asp:DataPager> NOTE: You can use more than one field within a single DataPager Control. Example: <asp:DataPager ID = “pager” runat = “server” PageSize = “10”> <asp:NextPreviousPagerField ShowFirstPageButton = “true” ShowNextPageButton = “false” ShowPreviosuPageButton = “true” ShowLastPageButton = “false”/> <asp:NumericPagerField/> </asp:DataPager> |
Browser Issues In IE there is a problem clicking next button or if you have taken it as Numeric pager field then clicking the next number it will not take you to the corresponding page. You have to click it twice to go to that page. Solution [1] You need to databind again on datapager_prerender() function sothat it will work fine. [2] There is a property of Datapager control i.e QueryStringField which you can use to sort out this problem. But when you are using QueryStringField it will databind ListView twice which is a performance issue. Also When you are using QueryString Field and navigating to other pages then it will display the page number in the URL which is not a good idea. |