Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1033379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:13:26+00:00 2026-05-16T14:13:26+00:00

I have a class that contains hierarchical data. I want to present this data

  • 0

I have a class that contains hierarchical data. I want to present this data in my ASP.net webapp using nested repeaters. How do I do this? I’ve only ever done one level of nesting, how do I do say five levels?

Each item can have zero or many sub items. I’m basically just indenting at each subleveling using some css stuff. I do not want to use the treeview control, I want to strictly stick with a repeater.

Update:
My data comes from a database. I have an item datatable with some basic properties.

Item
{
   ID,
   Name,
   Description,
   ...
}

Then I have a many to many table with:

Parent
{
   ParentID,
   ChildID
}

I’m iterating through each item and displaying its children; and its children’s children. I assume this would best be accomplished with nested repeaters, but I could be wrong.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:13:26+00:00Added an answer on May 16, 2026 at 2:13 pm

    It’s always cleaner to deal with the datasource than messing about with ItemDataBound, but this is even more the case when nesting Repeaters:

    <asp:Repeater DataSource="<%#ColOfCol%>" runat="server">
      <ItemTemplate>
        <tr>
          <asp:Repeater DataSource="<%#Container.DataItem%>" runat="server">
            <ItemTemplate>
              <td><%#SomeExtractingMethodLikeEval()%></td>
            </ItemTemplate>
          </asp:Repeater>
        </tr>
      </ItemTemplate>
    </asp:Repeater>
    

    The inner datasource could also be an evaluated property, or a call to a method that returns the enumeration wanted. Just be aware that it will be called with an object. I prefer to write the specific version, and then overload:

    protected IEnumerable<string> GetNames(Family fam)
    {
      foreach(Person p in fam.Members)
        yield return p.FirstName + " " + p.Surname;
    }
    protected IEnumerable<string> GetNames(object famObj)
    {
        return GetNames((Family)famObj);
    }
    

    One thing to be aware of is that if you want to get the current object in the parent repeater than you have to obtain it with:

    ((RepeaterItem)Container.Parent.Parent).DataItem
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that contains data from some model. This class has metadata
I have this class that contains vars for db connection; Imports Microsoft.VisualBasic Imports System.Data.SqlClient
I have a class that contains an array. I want this array to be
I have a class that contains a boolean field like this one: public class
I have a class that contains a static number of objects. This class needs
I have a class that contains, among other things, an std::list. I want to
I have a class called Shop that contains data members ( NSString , NSInteger
This is a C++ question. I have a class that contains a string: class
I have a class that contains some data, and I would like to add
If I have a class that contains private static data allocated on the heap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.