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

Manipulating RadMenuItem in Code-behind with SiteMap DataSource

1 Answer 148 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Pat O'Neil
Top achievements
Rank 1
Pat O'Neil asked on 19 Jul 2009, 07:11 PM
I am building a fairly simple menu with the RadMenu Control and it works well, but I would like to be able to hide certain menu items based on an attribute in the .sitemap file.  ie.  hideFromMenu="true"

I thought I would be able to do this in a RadMenu_OnItemDataBound type of method where I would just check the attribute of the sitemap node and hide the ones that are set to be hidden. 

This doesn't seem to be the case and I'm sure other people have had a similar issue. 

Has anyone done this yet?

thanks

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 20 Jul 2009, 07:47 AM
Hello Pat O'Neil,

Using the ItemDataBound event is the recommended approach. There you can cast e.Item.DataItem to SiteMapNode and check the appropriate attribute. Here is a code snippet which illustrates the idea:

    protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)
    {
        SiteMapNode node = (SiteMapNode)e.Item.DataItem;

        if (node["myAttribute"] == "true")
        {
            e.Item.Owner.Items.Remove(e.Item);
        }
    }

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Menu
Asked by
Pat O'Neil
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or