User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 455,982 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,776 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 2807 | Replies: 12
Reply
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

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

  #11  
Dec 2nd, 2007
there are two queries, one pulls the category names and the category ID's. The second query pulls all records that relate to any of those ID's. It seems impossible, at this moment, at least with the current method I am using.
Reply With Quote  
Join Date: Nov 2008
Posts: 1
Reputation: selenachan is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
selenachan selenachan is offline Offline
Newbie Poster

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

  #12  
5 Days Ago
I have a very similar problem where I have a nested repeater and I want to limit the child items to 5. Following is my code... any help would be much appreciated...

  1. <asp:Repeater id="parentRepeater" runat="server">
  2. <itemtemplate>
  3. <br /><br /><b>
  4. <%#DataBinder.Eval(Container.DataItem, "category")%>
  5. <img src='images/divider/<%#DataBinder.Eval(Container.DataItem, "ID")%>_divider.jpg' alt="<%#DataBinder.Eval(Container.DataItem, "category")%>"/>
  6. </b>
  7. <br>
  8. <asp:repeater id="childRepeater" runat="server" datasource='<%# Container.DataItem.Row.GetChildRows("myrelation") %>'>
  9. <itemtemplate>
  10.  
  11. <a href='products.aspx?catID=<%#container.dataitem("CatID")%>&pID=<%#container.Dataitem("ID")%>' class="categoryLink">
  12. <img src='images/products/<%#Container.DataItem("PNumber")%>t.jpg'alt="<%#Container.DataItem("PName")%>" border="1" \></a>
  13.  
  14. Private Sub Load_CategoryRepeater()
  15.  
  16. Dim CatId As String
  17. CatId = Request.QueryString("catID")
  18. Dim cnn As SqlConnection = New SqlConnection("Server=localhost;Database=xxx;Integrated Security=SSPI")
  19. Dim cmd1 As New SqlDataAdapter("select * from category where parentID = '" _
  20. & CatId & "'", cnn)
  21.  
  22.  
  23. 'Create and fill the DataSet.
  24. Dim ds As New DataSet()
  25. cmd1.Fill(ds, "category")
  26.  
  27. Dim cmd2 As New SqlDataAdapter _
  28. ("SELECT Category.Category, Products.PNumber, Products.ID, Products.PName, Products.PPrice, Products.PDescription, Products.CatID, Category.ID AS CategoryID, Category.ParentID FROM Category INNER JOIN Products ON Category.ID = Products.CatID Where Category.ParentID ='" _
  29. & CatId & "'", cnn)
  30.  
  31. cmd2.Fill(ds, "product")
  32.  
  33. ds.Relations.Add("myrelation", ds.Tables("category").Columns("ID"), ds.Tables("product").Columns("CatID"))
  34.  
  35.  
  36. parentRepeater.DataSource = ds.Tables("category")
  37. parentRepeater.DataBind()
  38.  
  39.  
  40. cnn.Close()
  41. End Sub
  42. </itemtemplate>
  43. </asp:repeater>
  44. </itemtemplate>
  45. </asp:Repeater>
  46.  


Originally Posted by shaulf View Post
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
Last edited by cscgal : 4 Days Ago at 1:45 pm. Reason: Added code tags
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

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

  #13  
5 Days Ago
For this, just update your query to select the top 5 results ...

SELECT TOP 5 Category.Cat....

This way it has only 5 records and is limited.
I answer pm's.
I answer questions.
I answer quickly.
I answer.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 9:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC