How to add Submenu with Item Template Programmatically

4 posts, 0 answers
  1. PC
    PC avatar
    1 posts
    Member since:
    Dec 2008

    Posted 08 Dec 2008 Link to this post

    I am evaluating the products.

    I have a mainmenu, and want to add submenu with item template from a datasource. 

    Thanks.
    Alfred
  2. Baatezu
    Baatezu avatar
    110 posts
    Member since:
    Aug 2007

    Posted 08 Dec 2008 Link to this post

    Check out this help topic on adding templates at runtime.
    http://www.telerik.com/help/aspnet-ajax/menu_menu_templates_run_time.html
    You will need to do some modifying to get it to work on only the submenu item, but it's doable.
  3. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Dec 2008 Link to this post

    Hi PC,

    Adding template controls to a menu item is really simple and easy. You no longer need to define a class that implements the ITemplate interface and the other cumbersome coding normally associated with this scenario. Simply use the Add method of the Controls collection of the menu item which will hold the control. Here is an example:

    CS:
    protected void Button2_Click(object sender, EventArgs e) 
        Button btnExport = new Button(); 
        btnExport.Text = "Export"
        radmenu1.Items[0].Items[0].Controls.Add(btnExport); 

    Thanks,
    Shinu.
  4. Alfred
    Alfred avatar
    32 posts
    Member since:
    Jan 2008

    Posted 09 Dec 2008 Link to this post

    Thanks all.
Back to Top