RadMenu Databind large collection

5 posts, 0 answers
  1. Koen L
    Koen L avatar
    34 posts
    Member since:
    May 2010

    Posted 29 Jun 2012 Link to this post

    We use the RadMenu control in one of our user controls.
    The page which uses this control render very slow.
    After profiling the page with a few tools we came to the conclusion the databinding of the RadMenu takes up 90% of the time spent generating the page.

    radMenu.DataSource = collection;

    The collection has about 1500 items in it. How can we optimize the performance, so the control can cope with such a large number of items in its datasource...

    Kind regards,
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Jul 2012 Link to this post

    Hi Koen,

    You can increase the performance of RadMenu using Web Service Load on Demand. Here is the sample code I tried based on your scenario which works as expected.

    <asp:SqlDataSource ID="SqlDataSource1" runat ="server" ConnectionString ="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT * FROM tree WHERE parent IS NULL " >
    <telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="true" DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="id" >
       <WebServiceSettings Path="menu.asmx" Method="GetChildren" />
          <telerik:RadMenuItemBinding Depth="0" ExpandMode="WebService" />

      public RadMenuItemData[] GetChildren(RadMenuItemData item, object context)
           SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM tree WHERE parent = '"+item.Value+"' ", con);
           DataTable dt = new DataTable();
           List<RadMenuItemData> result = new List<RadMenuItemData>();
              foreach (DataRow row in dt.Rows)
                 RadMenuItemData itemData = new RadMenuItemData();
                 itemData.Text = row["name"].ToString();
                 itemData.Value = row["id"].ToString();
                 if (Convert.ToInt32(row["ChildrenCount"]) > 0)
                     itemData.ExpandMode = MenuItemExpandMode.WebService;
              return result.ToArray();
           return null;

    Hope this helps.

  3. Koen L
    Koen L avatar
    34 posts
    Member since:
    May 2010

    Posted 04 Jul 2012 Link to this post

    Thanks. Discovered this method already and works great.

    I only have one problem. The radmenu needs to load different items based on the current language. Can I use the context object to deliver the language index to the webservice?

    If yes. Where do I need to set this context object?
  4. Peter
    Peter avatar
    6637 posts

    Posted 05 Jul 2012 Link to this post

    Hello Koen,

    RadMenu does not have the necessary client API to support this scenario. Please, accept our apology for this limitation of the control.

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Koen L
    Koen L avatar
    34 posts
    Member since:
    May 2010

    Posted 06 Jul 2012 Link to this post

    So there is no way to add additional information to the RadMenuItemData item or object context in the webservice?
Back to Top