Both static and databound items

5 posts, 2 answers
  1. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 07 Jun 2010 Link to this post

    I have structure shown below. What I would like to do is filling first item's (Products) sub items with Hierarchical data which comes from ObjectData source. How can I achive this?

    Thanks in advance.

    <telerik:RadMenu ID="RadMenu1" runat="server" Width="1000px"  
        EnableShadows="True"
        <Items> 
            <telerik:RadMenuItem runat="server" PostBack="False" Text="Products"
                <Items> 
     
                </Items> 
            </telerik:RadMenuItem> 
            <telerik:RadMenuItem runat="server" Text="Text Here" PostBack="False"
                <Items> 
                    <telerik:RadMenuItem runat="server" NavigateUrl="#" Text="Sub A"
                    </telerik:RadMenuItem> 
                    <telerik:RadMenuItem runat="server" NavigateUrl="#" Text="Sub B"
                    </telerik:RadMenuItem> 
                    <telerik:RadMenuItem runat="server" NavigateUrl="#" Text="Sub C"
                    </telerik:RadMenuItem> 
                </Items> 
            </telerik:RadMenuItem> 
        </Items> 
    </telerik:RadMenu> 
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Jun 2010 Link to this post

    Hello Barbaros,

    Setting AppendDataBoundItems property of RadMenu to True preserves the items that are already present in the menu. This lets you bind RadMenu to use both unbound and bound modes.
    Binding to object-based data sources


    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 08 Jun 2010 Link to this post

    Thanks for your help. One more problem, how can I set items display order? I mean, on my example above menu item with text "Text Here" is shown first, then DataBound menu item comes. But I want display DataBound menu item first.

    Thanks in advance
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Jun 2010 Link to this post

    Hello Barbaros,

    I am not sure about any property to set the items display order as you said. But, if you are creating the items programatically, then the items will display after the databound items. Give a try with following approach.

    C#:
     
        protected void RadMenu1_DataBound(object sender, EventArgs e)  
        {  
            RadMenuItem item1 = new RadMenuItem("Text Here");  
            RadMenuItem itemA = new RadMenuItem("Sub A");  
            RadMenuItem itemB = new RadMenuItem("Sub B");  
            item1.Items.Add(itemA);  
            item1.Items.Add(itemB);  
            RadMenu1.Items.Add(item1);  
        } 


    Regards,
    Princy.
  6. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 08 Jun 2010 Link to this post

    Thanks again. Your solution is what I am doing currently. I wonder if there is a property or trick that do same functionally at design time. For simple menus its ok but for more complex ones defining menu at run time is really time consuming and cumbersome.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017