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

Find Item by ID

1 Answer 286 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Tab Alleman
Top achievements
Rank 1
Tab Alleman asked on 15 Jun 2010, 03:07 PM
It seems to be the case that there is no way to find a menu item by its ID with server-side code.    Is this correct?   Please tell me I'm wrong.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Jun 2010, 08:25 AM
Hi,

As far as I know, there is no direct method for RadMenu to access the item using ID. RadMenu allows accessing items according to url, text, value there is GetAllItems method to access all the RadMenuItems, which is described in the documentation.

But, you can explicitly check for the item by iterating through all the items as shown in the sample code.

CS:
 
    string value = "";              
    foreach (RadMenuItem item in RadMenu1.GetAllItems()) 
    { 
        if (item.Attributes["id"] == "id2")  // I set id attribute to each menuitem 
        { 
            value = item.Value; 
            break
        } 
    } 
    RadMenuItem findItem = RadMenu1.FindItemByValue(value); 
    findItem.Text = "Got the item"


-Shinu.
Tags
Menu
Asked by
Tab Alleman
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or