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

  • Home
  • SEARCH
  • 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 8847555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:13:05+00:00 2026-06-14T12:13:05+00:00

I have a database with a table called categories. The table has 3 columns:

  • 0

I have a database with a table called “categories”. The table has 3 columns:
1. ID
2. Name
3. ParentID.

id | Name    |ParentID
_____________________
1  | John    | 0
2  | Charlie | 1
3  | Vasily  | 1
4  | David   | 2
5  | Edward  | 3

So John is the parent for Charlie and Vasily, David is the child of Charlie and Edward is the child of Vasily.
The question is:
How can i create and populate some panels for each category, considering that the child panels must be inside their parent panels? The question is allmost the same as this one here however i realy realy need it to be with panels instead of treeview.
Thank You.

  • 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-14T12:13:07+00:00Added an answer on June 14, 2026 at 12:13 pm

    you should change the code as it is

    public class MyObject
    {
        public int Id;
        public int ParentId;
        public string Name;
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            List<MyObject> list = new List<MyObject>();
            list.Add(new MyObject() { Id = 1, Name = "Alice", ParentId = 0 });
            list.Add(new MyObject() { Id = 2, Name = "Bob", ParentId = 1 });
            list.Add(new MyObject() { Id = 3, Name = "Charlie", ParentId = 1 });
            list.Add(new MyObject() { Id = 4, Name = "David", ParentId = 2 });
    
            BindTree(list, null);
        }
    }
    
    private void BindTree(IEnumerable<MyObject> list, Panel parentPanel)
    {
    
        var nodes = list.Where(x => parentPanel == null ? x.ParentId == 0 : x.ParentId == int.Parse(parentPanel.ID));
        foreach (var node in nodes) {
            Panel newPanel = new Panel() { ID = node.Id.ToString() };
            if (parentPanel == null) {
                Panel1.Controls.Add(newPanel);
            } else {
                parentPanel.Controls.Add(newPanel);
            }
            BindTree(list, newPanel);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok... I have a database table called employees.. This has columns called ID, Name,
I have a database table called users This table has two columns (that are
I have a database, called 'catalog', and a table, called 'categories'. The table has
In database table I have column called options . It has type of integer
I have a table called Products in my database. It has a couple of
I have a table called routes within my database where each route has an
I have a Database with a table called users(_id,name). I am using the following
I have a database with a table called shuffledQuestions with 2 columns category_id and
I have a database table called posts that has 'id, title, slug and content'
I have a database table called user where I have some columns. One of

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.