views:

28

answers:

1

Hi friends,
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 category?
  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!.

+1  A: 

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 http://stackoverflow.com/questions/4221/linqdatasource-can-you-limit-the-amount-of-records-returned

Marko
you know I used LinqDataSource and DBML.
mahdiahmadirad
Check this answer out http://stackoverflow.com/questions/4221/linqdatasource-can-you-limit-the-amount-of-records-returned
Marko
I've included the link in the answer as well. There's no reason to limit from the Repeater since your DS will still be selecting all the records. If you still can't get it to work, I'll write you a c# solution :) Good luck
Marko