Need help on Nested Repeater. Need to limit queries.

Reply

Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Need help on Nested Repeater. Need to limit queries.

 
0
  #1
Nov 26th, 2007
Hey, I created a datalist with a nested repeater. In the nested repeater, I need to limit the amount of records shown (only 10 allowed). However, just limiting the second query into the dataset doesn't work, only grabs 10 records. So I need to figure out a way of only showing 10 results for each. Basically, let's say this is my setup:
  1. category1
  2. - 1
  3. - 2
  4. - 3
  5. - 4
  6. ...
  7. - 10
  8. - 11
  9. - 12
  10. - 13
  11.  
  12. category2
  13. - 1
  14. - 2
  15. - 3
  16. - 4
  17. ...
  18. - 20
  19. - 21
  20. - 22
  21. - 23
  22.  
  23. category3
  24. - 1
  25. - 2
  26. - 3
  27. - 4
  28. ...
  29. - 16
  30. - 17
  31. - 18
  32. - 19

Now I need to limit each category to 10 rows only. There are about 22 categories and about 10,000 results. Obviously I need to do my best to just limit it to 220 results, not 10,000!! Any help will be grateful. Thank you.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #2
Nov 27th, 2007
anyone have any suggestions? I suppose I can put a loop on and trully limit the amount per sub repeater, but that doesn't help the fact that my query will still return 10,000 results. This is especially worse as I am storing it in the cache to use in a dataset.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #3
Nov 28th, 2007
anyone? this will help tons.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 18
Reputation: shaulf is an unknown quantity at this point 
Solved Threads: 4
shaulf's Avatar
shaulf shaulf is offline Offline
Newbie Poster

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #4
Nov 29th, 2007
Originally Posted by SheSaidImaPregy View Post
anyone? this will help tons.
I read through your question and could not quit understand the problem. How are you getting the data? from a database? why not restrict the number of records there? You could filter the dataset using the "DefaultView" row filter - http://msdn2.microsoft.com/en-us/lib...er(VS.71).aspx
. Send me your code and I will take a look.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #5
Nov 29th, 2007
It is dealt through a nested repeater. So the first repeater has no limits. It will show all 22-50 results needed. The second query (nested one), I would like to limit to 10 records per repeater. By limiting inside the query using LIMIT 10 or whatever, limits the results to all repeaters so that only 10 records are shown. So basically, this is what I want:
  1. Category 1 Category 2 Category 3
  2. 1 result 1 result 1 result
  3. 2 result 2 result 2 result
  4. 3 result 3 result 3 result
  5. 4 result 4 result 4 result
  6. .........
  7. 9 result 9 result 9 result
  8. 10 result 10 result 10 result
  9.  
  10. '' However, with retrieving the results it will display all. So with 10,000 results, you can imagine how big of a list it would be. By limiting the inner query to 10, it will bind 4 results to category 1, 3 to category 2, 3 to category 3. I have put a loop on currently that limits the amount of records to 10 per category, but the query will still return 10,000 results, and store all 10,000 in the dataset. If you still need my code, just ask for it once more and I will put it up!
Last edited by SheSaidImaPregy; Nov 29th, 2007 at 3:08 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 18
Reputation: shaulf is an unknown quantity at this point 
Solved Threads: 4
shaulf's Avatar
shaulf shaulf is offline Offline
Newbie Poster

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #6
Nov 30th, 2007
mmm...why are the nested repeater not restricted? Are you not using the ItemDataBound event to populate it? When doing so you could control how many records are process could you not?
Shaul
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #7
Nov 30th, 2007
yes i am using the itemdayabound method. could you explin please, and does it help against quering 10,000 rows when only 220 are needed?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 18
Reputation: shaulf is an unknown quantity at this point 
Solved Threads: 4
shaulf's Avatar
shaulf shaulf is offline Offline
Newbie Poster

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #8
Nov 30th, 2007
Originally Posted by SheSaidImaPregy View Post
yes i am using the itemdayabound method. could you explin please, and does it help against quering 10,000 rows when only 220 are needed?
Hi,

displaying any listed data in a web page is a three steps process (basically):
  1. Getting the data from a database\source
  2. processing the data
  3. displaying the data
When you got the data in the first step you should get the minimum amount required. For the performance stand point there is no one answer; is it better to fetch all at once or go back and forth (in the item data bound) fetching the second level groups. It depends on the database size, network\location and number of sub groups queried in the item data bound. As a rule I probably would go with a very quick small query for the categories - something like a hundred results then query the database in the item data bound. Databases are better at querying data than .NET DataSets. However if the database is huge or far away from the web server I would think again.

To cut a long story short query the top level lets say school classes. Bind the DataTable to the list and in the Item Data Bound Query the database for each class students.

Another thing to consider is to show just the top level (classes in my example) and provide a link to the students what I call Card View. This way you do not need to bother with processing records the user might not be interested with (the down side is the need for the user to click twice to get the data).

if you still find it unclear send me your code and I will take a look...

Good Luck
Shaul
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #9
Nov 30th, 2007
Nope, makes perfect sense. The server is in the same building as the mysql server, so that is fine. I would just hate to tap the database.. 25 times instead of once.. you know? But if tapping the database 25 times and only retreving a total of 275 records compared to 10,000 (at the moment, but later above 100,000), the difference might be huge. Thanks.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 86
Reputation: justapimp is an unknown quantity at this point 
Solved Threads: 1
justapimp justapimp is offline Offline
Junior Poster in Training

Re: Need help on Nested Repeater. Need to limit queries.

 
0
  #10
Dec 1st, 2007
Are you also getting the category information with your query result? If you are, you could select TOP 10 record of each category and use the foreach method to filter out the categories and populate your nested repeater.

In ASP.NET this seems a bit difficult, but in PHP this problem could be resolved without having to pre-filter your result.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 4827 | Replies: 12
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC