Background
I have often read the common question in forum posts of how to do paging in a DataList so by considering those requirements I have decided to write this article. In a DataList there is no direct method to do paging as in a GridView. To do paging in a DataList the PagedDataSource class provides the properties and methods to do the paging in the datalist. So let us start from the defination of PagedDataSource so beginners can also understand.
PagedDataSource
PagedDataSource is a sealed class that provides the properties and methods to do paging and other tasks in the DataList.
Properties of PagedDataSource
The following are (most of) the common properties of the PagedDataSource class:
- AllowCustomPaging
- AllowPaging
- AllowServerPaging
- Count
- CurrentPageIndex
- DataSource
- DataSourceCount
- FirstIndexInPage
- IsCustomPagingEnabled
- IsFirstPage
- IsLastPage
- IsPagingEnabled
- IsReadOnly
- IsServerPagingEnabled
- IsSynchronized
- PageCount
- PageSize
- SyncRoot
- VirtualCount
Methods of PagedDataSource
- CopyTo
- GetEnumerator
- GetItemProperties
- GetListName
I hope you have learned about the PagedDataSource. Now let us see the practice. Suppose we have an Employee table with the following records: