Click here to Skip to main content
15,917,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I build an Accordion control in vb code (as shown below) that calls the ItemDatabound event.

I have an aspx declarative example as a test which works, this uses a HeaderTemplate and ContentTemplate.

I'm thinking that is where I may be wrong, may be I need to use Accordion1.ContentTemplate.

Does anyone have an example of an Accordion built this way, and calling Item events?


VB
 With Accordion1

            '- add header -
            Dim head As New Label
            head.ID = "LblHeader"
            head.Text = "label"

            Dim accpane As New AjaxControlToolkit.AccordionPane
            accpane.HeaderContainer.Controls.Add(head)

            '- add Data -
            Dim Data As New Label
            Data.ID = "LblData"
            Data.Text = "label"

            accpane.ContentContainer.Controls.Add(Data)

            Accordion1.Panes.Add(accpane)

End With


Protected Sub Accordion1_DataBound(ByVal sender As Object, ByVal e As AjaxControlToolkit.AccordionItemEventArgs) Handles Accordion1.ItemDataBound

       '- Do something

End Sub
Posted
Updated 10-Feb-10 5:26am
v3

Hi
on your aspx page add this attribute in the Accordion tag.

onItemDataBound="Accordion1_DataBound"

Suppoose your accordion Tag on aspx page is then add onItemDataBound="Accordion1_DataBound" in the tag as shown below:

<ajaxToolkit:Accordion
ID="Accordion1"
runat="Server"
SelectedIndex="0"
HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent"
AutoSize="None"
FadeTransitions="true"
TransitionDuration="250"
FramesPerSecond="40"
RequireOpenedPane="false"
SuppressHeaderPostbacks="true" onItemDataBound="Accordion1_DataBound">
<Panes>
<ajaxToolkit:AccordionPane
HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent">
<Header> . . . </Header>
<Content> . . . </Content>
</ajaxToolkit:AccordionPane>
.
.
.
</Panes>
<HeaderTemplate>...</HeaderTemplate>
<ContentTemplate>...</ContentTemplate>
</ajaxToolkit:Accordion>

Hope this will solve your issue.

Thanx,
Adil...:))
 
Share this answer
 
Thanks for the response but not what I was looking for.

I am trying to work out how to do this in only code-behind, and NOT aspx declarative code.
 
Share this answer
 
Hi
In that case write an event handler for item data bound event, that will do the job.


Thanx,
Adil...:))
 
Share this answer
 
Maybe my original post was not specific enough.

If I build an Accordion in VB code-behind, in the style sugested in my original post, the Accordion1_Databound event never gets called. I think I must be missing something when building the Accordion. I noticed the aspx had used HeaderTemplate and ContentTemplate, where my vb code example is not.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900