Using a DataPager with the GridView Control Implementing IPageableItemContainer

One of the new controls that shipped with ASP.NET 3.5 is the DataPager. The big advantage with the DataPager is that it is decoupled from the data-bound control it provides paging support for. It can be placed anywhere within the data-bound control's control hierarchy (like contained within the LayoutTemplate of the ListView). It can also be placed on its own outside of the data-bound control as well. Gridview doesnot supports directly with DataPager. To enable support for gridview you must extend the gridview and implment the IPageableItemContainer Interface. Implementing IPageableItemContainer is simple.

  1. Create a class inheriting from the grid view implementing IPageableItemContainer interface class.
  2. Implement the methods as given below. Following example shows the example of repeater. You can extend gridview like as repeater shown in the following code snippet.

View this post for sample code and further details

blog comments powered by Disqus