This is a migrated thread and some comments may be shown as answers.
PanelBar adding dynamically created controls
1 Answer 51 Views
This is a migrated thread and some comments may be shown as answers.
Tex
Top achievements
Rank 1
Tex asked on 15 Jun 2009, 12:38 PM

Hello !

i've got a question about Telerik RadPanelBar control.

For example we've got a RadPanelBar control on form :

        <telerik:RadPanelBar ID="testPanelBar" runat="server">
       
</telerik:RadPanelBar>

and a button which adds a new item to this RadPanelBar at runtime:

        RadPanelItem newParentItem = new RadPanelItem();
       
RadPanelItem newChildItem = new RadPanelItem();
        newChildItem
.Controls.Add(new RadTextBox());
        newChildItem
.Text = "wazzap";
        newParentItem
.Items.Add(newChildItem);
        languagesPanelBar
.Items.Add(newParentItem);

when i click button, new RadPanelItem is added with all child controls(in this case it's RadTextBox in child item)

when button is clicked second time, second RadPanelItem is added with all controls, but this time RadTexBox control dissapeared from first RadPanelItem. 

And same when button is clicked for third time, new item added with all controls, but RadTextBox will dissapear from 1st and 2nd items.

am i doeing something wrong when dynamically adding items ?

Thank You !

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 19 Jun 2009, 02:48 PM
Hi Tex,

Try with the following approach and see whether it helps.

CS:
 
 protected void Button1_Click(object sender, EventArgs e) 
    { 
        
        RadPanelItem newParentItem = new RadPanelItem(); 
        RadPanelItem newChildItem = new RadPanelItem(); 
        
        newParentItem.Items.Add(newChildItem); 
        languagesPanelBar.Items.Add(newParentItem); 
        newChildItem.Text = "wazzap"
        newParentItem.Text = "zxzxz"
        for(int i=0;i<=languagesPanelBar.Items.Count-1;i++) 
        { 
            languagesPanelBar.Items[i].Controls.Add(new RadTextBox()); 
        } 
 
 
    } 


Regards
Shinu.
Asked by
Tex
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or