Adding Items at the third level of and existing Menu

3 posts, 0 answers
  1. Peter Ivanov
    Peter Ivanov avatar
    6 posts
    Member since:
    Oct 2009

    Posted 22 Oct 2009 Link to this post

    Hi,

    I'm struggling to find a way to add items to the second level of an existing RadMenu coded in ASP using my VB. I know I can create the whole menu in VB but i really don't want to go through all that trouble if there is a better way.

    My ASP looks like this:

     

    <telerik:RadMenu runat="server" ID="radmenu1" Skin="Sunset" EnableEmbeddedSkins="false" Width="895px">  
        <Items> 
            <telerik:RadMenuItem Text="HOME" NavigateUrl="~/" /> 
            <telerik:RadMenuItem Text="LINK2" NavigateUrl="~/Link1.aspx" /> 
            <telerik:RadMenuItem Text="LINK4">  
                <Items> 
                    <telerik:RadMenuItem Text="LINK4.1" NavigateUrl="~/Link4.1" /> 
                    <telerik:RadMenuItem Text="LINK4.2" NavigateUrl="~/Link4.2" /> 
                    <telerik:RadMenuItem Text="LINK4.3"/>  
                    <%--THIS IS WHERE I WANT TO ADD ITEMS--%> 
                </Items> 
            </telerik:RadMenuItem> 
            <telerik:RadMenuItem Text="LINK5" Visible="true" NavigateUrl="~/Link5.aspx" /> 
        </Items> 
    </telerik:RadMenu>
     
     

    And my VB:

    Dim sConStr As String = ConfigurationManager.ConnectionString("MyConnectionString").ConnectionString  
    Dim sSQL As String = "" 
    Dim cm As SqlCommand  
     
    sSQL = "SELECT Text, ID, FROM Table " 
     
    cm = New SqlCommand(sSQL, New SqlConnection(sConStr))  
    cm.Connection.Open()  
    dr = cm.ExecuteReader  
     
    Dim oRadMenuItem As New RadMenuItem  
     
     Do While dr.Read  
     
        oRadMenuItem = New RadMenuItem  
        oRadMenuItem.Text = dr("Name")  
        oRadMenuItem.NavigateUrl = "TARGETLINK?id=" & dr("ID")  
        radmenu1.Items(4).Items(4).Items.Add(oRadMenuItem)  
     
     Loop 
     
    cm.Connection.Close()  
     
     

     Clearly this is not the way to do this. Any help will be greatly appreciated.

  2. Yana
    Admin
    Yana avatar
    4911 posts

    Posted 23 Oct 2009 Link to this post

    Hi Peter,

    I suggest you bind the whole treeview using  ID to ParentID relationship to establish a hierarchy as it's explained here.
     
    Best wishes,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Peter Ivanov
    Peter Ivanov avatar
    6 posts
    Member since:
    Oct 2009

    Posted 23 Oct 2009 Link to this post

    Thanks for the adivce, I did look that up, and it works like a charm.
Back to Top