How we add dynamically Lables and Button in Panel bar when user click on Button?

3 posts, 0 answers
  1. Adeel
    Adeel avatar
    8 posts
    Member since:
    Oct 2012

    Posted 17 Oct 2012 Link to this post

    Kindly see my picture it describe my scenario.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Oct 2012 Link to this post

    Hi Adeel,

    Following is the sample code that I tried based on your scenario.

    ASPX:
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" >
         <Items>
             <telerik:RadPanelItem Text="RadPanelItem1">
             </telerik:RadPanelItem>
         </Items>
    </telerik:RadPanelBar>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" />

    C#:
    protected void Button1_Click(object sender, EventArgs e)
        {
            CustomContentTemplate template = new CustomContentTemplate();
            template.InstantiateIn(RadPanelBar1.Items[0]);
            RadPanelBar1.DataBind();
        }
     
     
    class CustomContentTemplate : ITemplate
    {
        public void InstantiateIn(Control container)
        {
            Button Button1 = new Button();
            Button1.Text = "Button1";
            container.Controls.Add(Button1);
            Label Label1 = new Label();
            Label1.Text = "Label1";
            container.Controls.Add(Label1);
        }
    }

    Please take a look into this documentation for more information.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Adeel
    Adeel avatar
    8 posts
    Member since:
    Oct 2012

    Posted 18 Oct 2012 Link to this post

    we require these Labels and Buttons in panel bar multiples times, when ever user click on Add Button than the group of these Labels and Buttons should be appear in panel bar. Now this time Labels and Buttons is appear in Panel bar but in only one time. How can we achieve in multiple time when User click on Add Button?

    Kindly reply me!
Back to Top