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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:48:30+00:00 2026-05-27T10:48:30+00:00

I have 3 levels deep repeters which bind to the following: MainCategories – bind

  • 0

I have 3 levels deep repeters which bind to the following:

MainCategories – bind to top repeater

SubCategories – bind to repeater in the 2nd level

SubSubCategories – bind to repeater in the 3rd level

Up to now, I acheived the databinding by using the itemdatabound event of the repeaters and passing the category id in order to filter the level beneath (e.g.: get all SubCategories for MainCategory 1, get all Subcategoris for MainCategory2).
This of course results in many trips to the database, and is inefficient.

Is there a way to make only 3 queries:
1. get all Main Categories and bind to top rpeater,
2. get all sub categories and bind somehow to 2nd level repeaters
3. get all subsub categories and bind to 3rd level repeaters.

How can this be acheived in asp.net c#?

  • 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-05-27T10:48:31+00:00Added an answer on May 27, 2026 at 10:48 am

    To do so, please follow below steps:

    First of all data into a DataTable say dataTableMainCategories and then filter SubCategories and SubSubCategories from dataTableMainCategories data table. Finally, at ItemDataBound write below code block and for SubCategories and SubSubCategories DataTable add desired column before importing filtered rows.

    Populate all main categories into a table and Bind to MainCategory repeater (rptrMainCategories) and the populate all sub and sub sub categories into dataTableCategories data table.

    protected void rptrMainCategories_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if(e.Item.ItemType== ListItemType.Item)
        {
            int subCategoryID = 5; // Pass your subcategory id to be filtered
            Repeater rptrSubCategories = (Repeater)e.Item.FindControl("rptrSubCategories");
            DataTable dtSubCategory = new DataTable();
            dtSubCategory.Columns.Add(); // Add your columns as SubCatagory
            DataRow[] dataRows = dataTableCategories.Select("SubCategoryID= " + subCategoryID + "");
            foreach (DataRow dataRow in dataRows)
            {
                dtSubCategory.ImportRow(dataRow);
            }
            rptrSubCategories.DataSource = dtSubCategory;
            rptrSubCategories.DataBind();
        }
    }
    
    protected void rptrSubCategories_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if(e.Item.ItemType== ListItemType.Item)
        {
            int subSubCategoryID = 55; // Pass your subsubcategory id to be filtered
            Repeater rptrSubSubCategory = (Repeater)e.Item.FindControl("rptrSubSubCategory");
            DataTable dtSubSubCategory = new DataTable();
            dtSubSubCategory.Columns.Add(); // Add your columns as SubCatagory
            DataRow[] dataRows = dataTableCategories.Select("SubSubCategoryID= " + subSubCategoryID + "");
            foreach (DataRow dataRow in dataRows)
            {
                dtSubSubCategory.ImportRow(dataRow);
            }
            rptrSubSubCategory.DataSource = dtSubSubCategory;
            rptrSubSubCategory.DataBind();
        }
    }
    

    Update

    If you use typed(custom typed) data then you can choose data in below ways:

    //Populate all main categories
    public List<Category>  MainCategories { get; set; }
    
    //Populate all sub and sub categories
    public List<Category> SubCategories { get; set; }
    

    At the event rptrMainCategories_ItemDataBound write below code and bind to repeater:

    List<Category> subCategory = SubCategories.Where(c => c.SubCategoryId = yourSubCategoryID);
    rptrSubCategories.DataSource = subCategory ;
    rptrSubCategories.DataBind();
    

    At the event rptrSubCategories_ItemDataBound write below code and bind to repeater:

    List<Category> subSubCategory = SubCategories.Where(c => c.SubSubCategoryId = yourSubSubCategoryID);
    rptrSubSubCategory.DataSource = subSubCategory ;
    rptrSubSubCategory.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 4 levels deep node structure, where the top most level is
I have a hierarchy of tables 3 levels deep (QualificaionType has many QualificationGroups, which
I have an object that is nested several levels deep which I'm referencing multiple
I have a xml which is max 3 levels deep. Now by using C#
I have a tree structure that can be n-levels deep, without restriction. That means
I have a TreeStore that you can drill into. It's only two levels deep.
I have multiple levels of the following: IF EXISTS(...) BEGIN IF NOT EXISTS(...) BEGIN
I have this nested loop that goes 4 levels deep to find all the
I have a asp.net master page that gets used by pages many /levels/deep/ I
I have a directory structure (multiple levels deep) of resources, that I would like

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.