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 7886603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:21:37+00:00 2026-06-03T05:21:37+00:00

I have three tables as follows: table 1 is called Cat1, table 2 is

  • 0

I have three tables as follows: table 1 is called Cat1, table 2 is called subcat1 and table three is called itemsTb. I have created relationships like this:

cat1 to subcat1 (one-to-many)
cat1 to itemstb (one-to-many)
subcat1 to itemstb (one-to-many)

I would like to display items in asp.net repeaters like this:

cat 1....
   ....item 1
   ....item 2
   ....item 3
cat 2
   subcat 1 .....
      .....item 1
      .....item 2
      .....item 3
cat 3.....
   ....item 1
   ....item 2

etc.

The schema of my tables is like this:

Table: cat
columns:
id      int
title   varchar

table  subcat
columns:
id     int
catid  int
title  varchar

table: items
columns
id         int
catid      int
subcatid   int
title      varchar

Anyone has any idea how can I display them using asp.net repeaters? Or do I have to structure my tables differently to make it work? Thanks a lot for your help.

  • 1 1 Answer
  • 0 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-06-03T05:21:38+00:00Added an answer on June 3, 2026 at 5:21 am

    All of the ASP.NET databound controls (Repeater, ListView, GridView, etc.) can use declarative data-binding for their DataSource. This isn’t very well documented IMO, but you can do something like:

    <asp:Repeater ID="rptCategory">
        <ItemTemplate>
            <asp:Repeater ID="rptSubcategory" DataSource='<%#Eval("Subcategories")%>'>
                 <ItemTemplate>
                    <asp:Repeater ID="rptItems" DataSource='<%#Eval("Items")%>'>
                        <ItemTemplate>
                            <%#Eval("Name")%>
                        </ItemTemplate>
                    </asp:Repeater>
                 </ItemTemplate>
            </asp:Repeater>
        </ItemTemplate>
    </asp:Repeater>
    

    The specifics of what you need to bind to the DataSource property depends on what your initial data (the one that rptCategory is bound to).

    If it’s a DataSet, then you need to build DataRelations and use the name of the appropriate DataRelation.

    If it’s a C# object, then you’ll want to use the name of a collection property.

    EDIT: Specifics on this particular schema follow….

    For your schema, you would need 2 nested repeaters – 1 to handle the items and 1 to handle the subcategories (which would have another nested repeater for its items).

    Using DataSets, you could do something like (note this is rough code, you’ll need to fill in some of the missing steps):

    var ds = ExecuteDataSet(
       @"SELECT Id, Title FROM Cat;
       SELECT Id, CatId, Title FROM SubCat;
       SELECT Id, CatId, SubCatId, Title FROM Items;"
    );
    ds.DataRelations.Add("Cat_SubCat", ds.Tables["Cat"].Columns["Id"], ds.Tables["SubCat"].Columns["CatId"]);
    ds.DataRelations.Add("Cat_Items", ds.Tables["Cat"].Columns["Id"], ds.Tables["Items"].Columns["CatId"]);
    ds.DataRelations.Add("SubCat_Items", ds.Tables["SubCat"].Columns["Id"], ds.Tables["Items"].Columns["SubCatId"]);
    
    this.rptCategory.DataSource = ds;
    this.rptCategory.DataBind();
    
    <asp:Repeater ID="rptCategory">
        <ItemTemplate>
            <h2>Category <%#Eval("Title")%></h2>
            <asp:Repeater ID="rptCatItems" DataSource='<%#Eval("Cat_Items")%>'>
                <ItemTemplate>
                    <h4>Item (Category) <%#Eval("Title")%></h4>
                </ItemTemplate>
            </asp:Repeater>
            <asp:Repeater ID="rptCatSubCat" DataSource='<%#Eval("Cat_SubCat")%>'>
                <ItemTemplate>
                    <h3>SubCategory <%#Eval("Title")%></h3>
                    <asp:Repeater ID="rptSubCatItems" DataSource='<%#Eval("SubCat_Items")%>'>
                        <ItemTemplate>
                            <h4>Item (SubCategory) <%#Eval("Title")%></h4>
                        </ItemTemplate>
                    </asp:Repeater>
                </ItemTemplate>
            </asp:Repeater>
        </ItemTemplate>
    </asp:Repeater>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables in the many-to-many format. I.e, table A, B, and AB
I have three tables: videos, videos_categories, and categories. The tables look like this: videos:
I have an Entity called Product, this entity, through table mapping, merges 6 tables
I have three tables, a user-table and two user-type tables. The user-type tables have
I have three tables like that: Articles IdArticle Title Content Tags IdTag TagName ContentTag
I have three tables. This query will write down the right answer (x-lines for
I have three tables -- stores, addresses and sales. Each store has one or
I have several databases that each have a table called, say, products . One
I have a table called Follow , with three fields: Id (autoincrement int), UserId

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.