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

Dynamic PanelItem

2 Answers 88 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
pmessina
Top achievements
Rank 1
pmessina asked on 08 Jul 2008, 01:23 AM
I'm trying to do something simple and have done this in the past but am having a bit of coders block. What I'm trying to do is on a button click dynamicaly add a RadPanelItem to a panel bar and populate it with a group of checkboxes. Every time I try to add a control to the underlying item it gets dumped on postback. A much simplified version of my code is below any help would definatly be appriciated. I'm trying to stay away from the Page_PreInit as I would like to put what I am working on in a usercontrol.

protected

void btnTEST_Click(object sender, EventArgs e)

{

for (int i = 0; i < 1; i++)

{

radpanelitem1.Items.Add(NewItem());

}

}

protected

RadPanelItem NewItem()

{

RadPanelItem o = new RadPanelItem("TEST PANEL");

CheckBox y = new CheckBox();

y.ID =

"TestCheckbox";

o.Controls.Add(y);

return o;

}

protected void Button1_Click(object sender, EventArgs e)

{

foreach (RadPanelItem r in radpanelitem1.Items)

{

foreach (Control y in r.Controls)

{

if (y is CheckBox)

System.Diagnostics.

Debug.WriteLine((y as CheckBox).Checked.ToString());

}

}

}

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 08 Jul 2008, 03:13 PM
Hi,

I suggest you add the checkboxes in the page_load event handler on every postback. You can see the attached project for reference.


All the best,
Yana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
pmessina
Top achievements
Rank 1
answered on 08 Jul 2008, 04:37 PM
Thank you very much for the test project and the prompt reply the test file is working and should be able to modify it the way I need it to. Again thank you.
Tags
PanelBar
Asked by
pmessina
Top achievements
Rank 1
Answers by
Yana
Telerik team
pmessina
Top achievements
Rank 1
Share this question
or