I am using the AJAXToolkit Accordion control and dynamically adding panes to it based on a query of the database. For example:
Jane logs in and pulls up the page with the accordion on it. In the database she has five rows in the todo_list table. So, I need to dynamically generate five panes that contain the info. from the table…but if Joe logs in he may have only three rows, and Josh may have fifteen – so I can never know how many an individual will have beforehand.
So, I need some way to dynamically name the variables (or is there another way to do this). For example, here is some pseudo-code of what I’m trying to accomplish:
Dim i as integer
For each row in todo_list
Dim ap + i as New AccordionPane
Add some info from the row to the pane
Next
You don’t need to create new variable names. You can simply add the newly created AccordionPane object to another object (like a List)
EDIT: Seeing as how the AccoridonPane is a managed control, I would suggest using a PlaceHolder control to hold your
Accordioncontrol, dynamically add AccordionPanes to the Accordion control and then add the Accordion to the PlaceHolder: