This is a migrated thread and some comments may be shown as answers.

Adding Items at the third level of and existing Menu

2 Answers 64 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Peter Ivanov
Top achievements
Rank 2
Peter Ivanov asked on 22 Oct 2009, 09:55 AM
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 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 23 Oct 2009, 06:24 AM
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.
0
Peter Ivanov
Top achievements
Rank 2
answered on 23 Oct 2009, 06:34 AM
Thanks for the adivce, I did look that up, and it works like a charm.
Tags
Menu
Asked by
Peter Ivanov
Top achievements
Rank 2
Answers by
Yana
Telerik team
Peter Ivanov
Top achievements
Rank 2
Share this question
or