This is a migrated thread and some comments may be shown as answers.
Adding children to root menu dynamically
3 Answers 32 Views
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 17 Aug 2011, 12:53 PM
I have a basic root level menu declared and I would like to add child to it dynamically. How do I go about this? Here is what I have declared:

                    <telerik:RadMenu ID="RadMenu1" runat="server" Width="188px">
                        <Items>
                            <telerik:RadMenuItem runat="server" Text="Calendars" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="Marketing" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="Sales" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="Supplier Relations" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="Training" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="IT" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="HR" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="Finance" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="Program Solutions" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="Other" Width="185px" Font-Bold="True"></telerik:RadMenuItem>
                        </Items>
                    </telerik:RadMenu>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 17 Aug 2011, 01:08 PM
Hello William,

You can add child items dynamically as shown below.
C#:
protected void Page_Load(object sender, EventArgs e)
{
     RadMenuItem child = new RadMenuItem();
     child.Text = "Child";
   RadMenuItem child1 = new RadMenuItem();
     child1.Text = "Child 1";
     child.Items.Add(child1);
     RadMenu1.Items.Add(child);
}

Thanks,
Princy.
0
William
Top achievements
Rank 1
answered on 17 Aug 2011, 01:17 PM
Hi Princy,

I tried this and it adds to the root level. What I would like, is to add this child to one of the other items at the root level. For instance, add "Child" to the "Calendars" menu item giving it another level. Can this be done?

William
0
William
Top achievements
Rank 1
answered on 17 Aug 2011, 03:31 PM
I figured this out... I now have the whole menu being dynamically generated.
Tags
Menu
Asked by
William
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
William
Top achievements
Rank 1
Share this question
or