Last post Dec 11, 2009 05:19 AM by eddigiff
Dec 10, 2009 04:28 AM|eddigiff|LINK
I am attempting to dynamically add panes to an accordion control and them iterate through the panes to retrieve user input and am having some difficulty. Thank you in advance for your assistance and suggestions...
The dynamic addition of the panes is easy enough, but when I attempt to iterate through the panes, the count of the items in the panes collection is 0, as if the dynamically created panes do not exist.
Code used to create:
EvaluationAnswerSet eas; //a user control, which has several properties to provide the data it will display.
//acEvaluationQuestions is my accordion control
//_Form is an instance of a class that provides the data.
foreach (DictionaryEntry qDE in _Form.QuestionSet)
q = (clsForm.Question)qDE.Value;
acp = new AjaxControlToolkit.AccordionPane();
acp.ID = "acp" + q.QuestionID.ToString();
eas = new EvaluationAnswerSet();
eas.ID = q.QuestionID.ToString();
eas.QuestionID = q.QuestionID;
eas.QuestionTypeID = q.QuestionType;
eas.AnswerSet = q.Answers;
the above code is working fine to generate the panes with the user control, but it is when I attempt to iterate through the panes to retrieve the user input that I run into an issue:
foreach (AjaxControlToolkit.AccordionPane a in acEvaluationQuestions.Panes)
//actions taken for the user input.
The accordion control panes collection has a count of zero, although there are several visible on the page. I am assuming that something is missing in the creation of the panes, but after scouring various boards and taking various promising suggestions,
I have not located a viable answer.
Help me Obi-Wan Kenobi, you are my only hope...
dynamically created asp.net accordion control iteration
Dec 11, 2009 05:19 AM|eddigiff|LINK
The solution is to move the creation of the accordion panes to the Page_Init.