Radmenu ItemDataBound event not firing

2 posts, 0 answers
  1. Mike
    Mike avatar
    1 posts
    Member since:
    Nov 2010

    Posted 24 Nov 2010 Link to this post

    Hello Telerik team,

    I'm trying to disable the menu items if the user is not in certain role's i don't know why the ItemDataBound is not firing.
    Please see the code below.
    ## ASPX file........
      <telerik:RadMenu ID="RadMenu1" Text="MenuOne" runat="server" AccessKey="P" DataNavigateUrlField="Url" EnableShadows="true" Skin="default" EnableEmbeddedSkins="False" CssClass="dropDown" OnItemDataBound="RadMenu1_ItemDataBound" OnItemClick="RadMenu1_ItemClick" ></telerik:RadMenu>

    ## CS file..............
     protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    string xmlFileName = "~/xml/MainMenu.xml";
                    RadMenu1.LoadContentFile(xmlFileName);
                }               
            }

            protected void RadMenu1_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e)
            {
                if (!Roles.IsUserInRole("Admin"))
                {
                    XmlElement element = (XmlElement)e.Item.DataItem;
                    if (element.Attributes["text"].Value == "Contact History")
                        e.Item.Enabled = false;
                }          
            }     
            protected void RadMenu1_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
            {   
                Response.Redirect(e.Item.Attributes["Url"].ToString());
            }  
  2. Yana
    Admin
    Yana avatar
    5002 posts

    Posted 25 Nov 2010 Link to this post

    Hi Hem,

    ItemDataBound event is fired when the menu is bound to a datasource as explained here. You can use XmlDataSource to load the items from the xml and fire the event. This approach is demonstrated here.

    All the best,
    Yana
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top