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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:53:09+00:00 2026-05-23T21:53:09+00:00

I need to create a nested linkbuttons in a asp.net page that looks like

  • 0

I need to create a nested linkbuttons in a asp.net page that looks like a treeview, but all are linkbuttons. Example is shown below:

ParentLinkButton1
    ChildLinkButton1
    ChildLinkButton2
    ChildLinkButton3
ParentLinkButton2
    ChildLinkButton1
    ChildLinkButton2
ParentLinkButton3
ParentLinkButton4
    ChildLinkButton1

I really don’t know how to do this. Based on my research this can be done using repeated control but I don’t know how to do that… Please if you can teach me step by step…

Thanks in advance!

  • 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-23T21:53:09+00:00Added an answer on May 23, 2026 at 9:53 pm

    The following example uses a ListView instead of a Repeater. ListViews are great because they’ll give you much more flexibility over a Repeater. Moreover, as you can see in the sample code below, binding the nested/child ListView can all be done declaratively without any code-behind.

    Example of what the following code will produce

    enter image description here

    ASPX

    <asp:ListView runat="server" ID="lvw">
        <LayoutTemplate>
            <ul>
                <li id="itemPlaceholder" runat="server" />
            </ul>
        </LayoutTemplate>
        <ItemTemplate>
            <li>    
                <asp:LinkButton runat="server" CommandArgument='<%# Eval("Name")%>'><%# Eval("Name")%></asp:LinkButton>
                <asp:ListView runat="server" ID="lvw2" DataSource='<%# Eval("Children")%>'>
                    <LayoutTemplate>
                        <ul>
                            <li id="itemPlaceholder" runat="server" />
                        </ul>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <li><asp:LinkButton runat="server" CommandArgument='<%# Eval("Name")%>'><%# Eval("Name")%></asp:LinkButton></li>
                    </ItemTemplate>
                </asp:ListView>
            </li>
        </ItemTemplate>
    </asp:ListView>
    

    C#

    lvw.DataSource = personList;
    lvw.DataBind();
    

    As you can see, in the C# code, I’ve created a list of “Person” as follows. Each Person object has a list of child Person objects. By creating your objects in this manner, binding the ListView is really as simple as I’ve shown. Use the Person object below to run a quick sample so you can see for yourself.

    Person object

    public class Person
    {
        public string name { get; set; }
        public List<Person> Children { get; set; }
    }
    

    For your test, you can create a Page_Load method as follows:

    protected void Page_Load(object sender, EventArgs e)
        {
            List<Person> personList = new List<Person>();
            Person person1 = new Person() { name = "Child 1" };
            Person person2 = new Person() { name = "Child 2" };
            List<Person> childPersonList1 = new List<Person>();
            childPersonList1.Add(person1);
            childPersonList1.Add(person2);
            Person person3 = new Person() { name = "Person 1" };
            person3.Children = childPersonList1;
            personList.Add(person3);
            Person person4 = new Person() { name = "Child 3" };
            Person person5 = new Person() { name = "Child 4" };
            List<Person> childPersonList2 = new List<Person>();
            childPersonList2.Add(person4);
            childPersonList2.Add(person5);
            Person person6 = new Person() { name = "Person 2" };
            person6.Children = childPersonList2;
            personList.Add(person6);
            Person person7 = new Person() { name = "Child 5" };
            Person person8 = new Person() { name = "Child 6" };
            List<Person> childPersonList3 = new List<Person>();
            childPersonList3.Add(person7);
            childPersonList3.Add(person8);
            Person person9 = new Person() { name = "Person 3" };
            person9.Children = childPersonList3;
            personList.Add(person9);
    
            lvw.DataSource = personList;
            lvw.DataBind();
        }
    

    See the following StackOverflow question to learn more about the differences between a Repeater and a ListView: Repeater, ListView, DataList, DataGrid, GridView … Which to choose?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create an ASP page (classic, not ASP.NET) which runs remote shell
I need to create a multi-dimensional (nested) hashtable/dictionary so that I can use syntax
I need to create N nested loops to print all combinations of a binary
Im programming in C#.NET. I want to create a nested class that can access
Whats is the best method to create nested checkboxlists in ASP.net? Should I be
I need to create a backup of a SQL Server 2005 Database that's only
I need to create a 2D int array of size 800x800. But doing so
I need to create an extension of a Flex component, which (obviously) means that
I need to create this function flat that's supposed to re-contract a new list

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.