开发者

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:

  1. How can I limit number of products showing under each category. I want to determine for example 5 newest products for each categor开发者_运维百科y?

  2. 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?
  3. 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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜