Asp.net C# binding repeater for a specified number of times
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#).
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.
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
精彩评论