Adding children to root menu dynamically

4 posts, 0 answers
  1. William
    William avatar
    22 posts
    Member since:
    May 2011

    Posted 17 Aug 2011 Link to this post

    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>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Aug 2011 Link to this post

    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.
  3. William
    William avatar
    22 posts
    Member since:
    May 2011

    Posted 17 Aug 2011 Link to this post

    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
  4. William
    William avatar
    22 posts
    Member since:
    May 2011

    Posted 17 Aug 2011 Link to this post

    I figured this out... I now have the whole menu being dynamically generated.
Back to Top