Hi guys,
I'm trying to populate dynamic data into the AJAX Accordion control. What I want is values taken from my db and posted into the Accordion panels (perhaps 20 to 30 panels per page). I can manage the paging issue (page 1, page 2, page 3 etc.) but how do I take a value from the database, place it in the header, then pick another column from the same row and place it into content, and then move onto the next row?
Any ideas?
Hello,
I made some study,
I could add dynamically it's header and content through the code.
Anyway, it works for me. if contents are simple I think O.K.
Following test code was in the Page_Load event. (VB, but code is very simple for C# to read)
Dim acdAs AjaxControlToolkit.Accordion =Me.FindControl("Accordion2")Dim pAs New AjaxControlToolkit.AccordionPaneDim lAs New Label l.Text ="content test"Dim l2As New Label l2.Text ="header test"Dim inpAs New HtmlInputButton("image")With inp .ID ="myImage_2" .Attributes.Add("src","../images/4-0.gif")End With p.HeaderContainer.Controls.Add(l2) p.HeaderContainer.Controls.Add(inp) p.ContentContainer.Controls.Add(l) acd.Panes.Add(p)
Thanks mate.
It makes sense, but I'm ending up with an error using the exact same code that you provided At runtime:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 24: Line 25:Line 26: acd.Panes.Add(p)
Any idea what seems to be going wrong here?
Okies i think I've worked this out. For some reason My.FindControl wasn't working for me so I changed the code to this instead:
Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Dim pAs New AjaxControlToolkit.AccordionPaneDim hAs New Label h.Text ="header text"Dim cAs New Label c.Text ="container text" p.HeaderContainer.Controls.Add(h) p.ContentContainer.Controls.Add(c) Accordion1.Panes.Add(p) Application("prodtype") = ProductTypeList.SelectedItem.TextEnd Sub
A reference directly to the Accordion control id helped. Many thanks for the help.
Cheers!
No comments:
Post a Comment