•
•
•
•
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
![]() |
•
•
Join Date: Nov 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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...
aspnet Syntax (Toggle Plain Text)
<asp:Repeater id="parentRepeater" runat="server"> <itemtemplate> <br /><br /><b> <%#DataBinder.Eval(Container.DataItem, "category")%> <img src='images/divider/<%#DataBinder.Eval(Container.DataItem, "ID")%>_divider.jpg' alt="<%#DataBinder.Eval(Container.DataItem, "category")%>"/> </b> <br> <asp:repeater id="childRepeater" runat="server" datasource='<%# Container.DataItem.Row.GetChildRows("myrelation") %>'> <itemtemplate> <a href='products.aspx?catID=<%#container.dataitem("CatID")%>&pID=<%#container.Dataitem("ID")%>' class="categoryLink"> <img src='images/products/<%#Container.DataItem("PNumber")%>t.jpg'alt="<%#Container.DataItem("PName")%>" border="1" \></a> Private Sub Load_CategoryRepeater() Dim CatId As String CatId = Request.QueryString("catID") Dim cnn As SqlConnection = New SqlConnection("Server=localhost;Database=xxx;Integrated Security=SSPI") Dim cmd1 As New SqlDataAdapter("select * from category where parentID = '" _ & CatId & "'", cnn) 'Create and fill the DataSet. Dim ds As New DataSet() cmd1.Fill(ds, "category") Dim cmd2 As New SqlDataAdapter _ ("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 ='" _ & CatId & "'", cnn) cmd2.Fill(ds, "product") ds.Relations.Add("myrelation", ds.Tables("category").Columns("ID"), ds.Tables("product").Columns("CatID")) parentRepeater.DataSource = ds.Tables("category") parentRepeater.DataBind() cnn.Close() End Sub </itemtemplate> </asp:repeater> </itemtemplate> </asp:Repeater>
•
•
•
•
Hi,
displaying any listed data in a web page is a three steps process (basically):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.
- Getting the data from a database\source
- processing the data
- displaying the data
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- SQL Injection Attack (Database Design)
- Big Repeater Question for you all (ASP.NET)
- Nested insert queries in a single query (MySQL)
- Nested For Loops (C++)
- SEO and AdWords API (Pay-Per-Click Advertising)
- MySQL nested query / joined query conversion help (MySQL)
Other Threads in the ASP.NET Forum
- Previous Thread: help me(pop up window for private chat
- Next Thread: Using Enterprise Library in asp.net(C#) web application



Linear Mode