This is a migrated thread and some comments may be shown as answers.

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

2 Answers 266 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Adeel
Top achievements
Rank 1
Adeel asked on 17 Oct 2012, 05:50 PM
Kindly see my picture it describe my scenario.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Oct 2012, 08:58 AM
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.
0
Adeel
Top achievements
Rank 1
answered on 18 Oct 2012, 06:45 PM
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!
Tags
PanelBar
Asked by
Adeel
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Adeel
Top achievements
Rank 1
Share this question
or