Wednesday, December 11, 2013

Paging with a ListView instead of a Repeater

I came across a task which required the functionality of a repeater (the ability to bind data and have it display in an HTML item template), but also the ability to page through the data (much like a GridView). There were some solutions out there, which required a lot of customization and involved too much time to make it worthwhile.

The ListView control however allows the display of bound data in an HTML template as well as other features such as: sorting, data editing, data insertions, and data deletions.

The following code is the basic structure for the ListView. The placeholder is where each item template will be placed (which is handy when you want a div or other HTML element to wrap around the data items). You can then add the DataPager, which allows for the ListView paging. You will also need the page properties changing event to ensure the paging works seamlessly.

No comments:

Post a Comment