Question

What is the best/easiest way to bind a repeater for a specified number of times, so for example if my list has 10 items and I just want to bind the first 2 items (using C#).

Was it helpful?

Solution

Filter the list of items at the data level, as close to the source as possible.

So if you only intend to show 2 items, request data for only 2 items instead of 10. If that's not possible, take the original data source and only supply the first 2 items to the repeater.

OTHER TIPS

SELECT TOP 2 * FROM Customer

Use the Keyword TOP to filter only the TOP N number of items...

For an example if you want only 4 most recently registered customers from a table Assuming there is a RegisteredDate attribute in your table...

SELECT TOP 4 * FROM Customer ORDER BY RegisteredDate DESC
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top