using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        rpbRelatedEntities.ItemTemplate = new PanelButtonTemplate();
        base.OnInit(e);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadPanelItem item1 = new RadPanelItem("Afdeling");
            
            RadPanelItem item11 = new RadPanelItem("Klant 1");
            item11.ItemTemplate = new PanelItemTemplate();
            item1.Items.Add(item11 );
            
            RadPanelItem item12 = new RadPanelItem("Klant 2");
            item12.ItemTemplate = new PanelItemTemplate();
            item1.Items.Add(item12);
      
            rpbRelatedEntities.Items.Add(item1);
            
            RadPanelItem item2 = new RadPanelItem("Persoon");

            RadPanelItem item21 = new RadPanelItem("Klant 1");
            item21.ItemTemplate = new PanelItemTemplate();
            item2.Items.Add(item21);

            RadPanelItem item22 = new RadPanelItem("Klant 2");
            item22.ItemTemplate = new PanelItemTemplate();
            item2.Items.Add(item22);

            rpbRelatedEntities.Items.Add(item2);
        }

        RadPanelBar1.DataBind();
        rpbRelatedEntities.DataBind();
    }

    class PanelButtonTemplate : ITemplate
    {
        public void InstantiateIn(Control container)
        {
            RadMenu radmenu = new RadMenu();
            radmenu.ID = "menu1";
            radmenu.Skin = "Default2006";

            RadPanelItem panel = (RadPanelItem)container;
         
            RadMenuItem item1 = new RadMenuItem("add");
            radmenu.Items.Add(item1);
            container.Controls.Add(radmenu);
        }
    }

    class PanelItemTemplate : ITemplate
    {
        public void InstantiateIn(Control container)
        {
            RadMenu radmenu = new RadMenu();
            radmenu.ID = "menu2";
            radmenu.Skin = "Default2006";

            RadMenuItem item1 = new RadMenuItem("del");
            radmenu.Items.Add(item1);
           
            container.Controls.Add(radmenu);
        }
    }


}