How to Conditionally determine Number of Data Items of a Nested Repeater Control!
I can use nested repeater to show my grouped data on a page (according to this: http://goo.gl/sH6g). In my case I have Category-Products structure and want to show each category and its products under it.
But here are my problems:- How can I limit number of products showing under each category. I want to determine for example 5 newest products for each categor开发者_运维百科y?
- How can I conditionally limit the number of products. For example I want to determine if there is no subcategory for a specific category show all products else show 5 newest products?
- Is repeater suitable for that work? if NOT which data control should I use?
Please give me some guidelines!.
You can limit the amount of records from your SQL statements.
For example, you can use SELECT TOP like this
SELECT TOP 5 * FROM Products Where CategoryId = 1
You can also use LIMIT
SELECT * FROM Products Where CategoryId = 1
LIMIT 5
Or for LINQ - see this post LinqDataSource - Can you limit the amount of records returned?
精彩评论