Here is what I use to create a collapsible panel dynamically. It's a function that takes in two other asp panels--one for the header and one for the content. the only thing this function needs knowledge of is the ID of the button used for the ImageControlID. You can probably do something to make it totally dynamic by looking through the controls in the header panel for an image control matching a pattern on the name.
The return from this function needs to be added to another panel that exists on the page.
private AjaxControlToolkit.CollapsiblePanelExtender PopulateCollapsiblePanel(Panel headerPanel, Panel bodyPanel)
{
collapsiblePan = new CollapsiblePanelExtender();
collapsiblePan.ExpandControlID = headerPanel.UniqueID;
collapsiblePan.CollapseControlID = headerPanel.UniqueID;
collapsiblePan.TargetControlID = bodyPanel.UniqueID;
collapsiblePan.Collapsed = false;
collapsiblePan.ID = "collapsiblePan";
collapsiblePan.ExpandedText = "Click to Collapse";
collapsiblePan.CollapsedText = "Click to Expand";
collapsiblePan.ImageControlID = "controlBtn";
collapsiblePan.ExpandedImage = "~/images/collapse_blue.jpg";
collapsiblePan.CollapsedImage = "~/images/expand_blue.jpg";
collapsiblePan.EnableViewState = true;
//collapsiblePan.SuppressPostBack = true;
collapsiblePan.EnableClientState = true;
return collapsiblePan;
From
http://www.developmentnow.com/g/8_2007_4_0_0_953045/dynamic-creation-of-CollapsiblePanel.ht
Posted via DevelopmentNow.com Group
http://www.developmentnow.com