Private void displayhotbooks ()
{
// Obtain the category information of all books
Ilist <Category> List = categorymanager. getallcategories ();
Int I = 0;
Foreach (Category item in List)
{
Accordionpane ap = new accordionpane ();
Label lbmenu = new label ();
Lbmenu. Text = item. Name;
AP. headercontainer. Controls. Add (lbmenu );
Accordion1.panes. Add (AP );
}
}
From the exception "_ Header", we can guess that it is related to the pane header. Therefore, we manually add a unique ID.
Private void displayhotbooks ()
{
// Obtain the category information of all books
Ilist <Category> List = categorymanager. getallcategories ();
Int I = 0;
Foreach (Category item in List)
{
Accordionpane ap = new accordionpane ();
Label lbmenu = new label ();
Lbmenu. Text = item. Name;
AP. headercontainer. Controls. Add (lbmenu );
AP. headercontainer. ID = "_ Header" + item. ID;
Accordion1.panes. Add (AP );
}
}
Then throw an exceptionFind multiple controls with the same ID "_ content. Findcontrol requires that the control have a unique ID. Haha, I almost forgot to add the Content ID manually in addition to the header and content. The final result is as follows:
Private void displayhotbooks ()
{
// Obtain the category information of all books
Ilist <Category> List = categorymanager. getallcategories ();
Int I = 0;
Foreach (Category item in List)
{
Accordionpane ap = new accordionpane ();
Label lbmenu = new label ();
Lbmenu. Text = item. Name;
AP. headercontainer. Controls. Add (lbmenu );
AP. headercontainer. ID = "_ Header" + item. ID;
AP. contentcontainer. ID = "_ content" + item. ID;
Accordion1.panes. Add (AP );
}
}