Manipulating RadMenuItem in Code-behind with SiteMap DataSource

2 posts, 0 answers
  1. Pat O'Neil
    Pat O'Neil avatar
    7 posts
    Member since:
    Jul 2009

    Posted 19 Jul 2009 Link to this post

    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?

  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 20 Jul 2009 Link to this post

    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")

    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.
Back to Top