Set Ajax Toolkit Accordion Selected AccordionPane by ID

6 December 2009 , ,

If you want to choose which AccodionPane is selected, you generally use the SelectedIndex command. However, if you want to select which AccordionPane is active by its ID and when you binded your data to your ajax accordion you set the ID of each AccordionPane you can use the below code:

This example is based on your accordion being called ‘Accordion1’.

'strPaneID is the name of the pane you want to find and set active
Dim strPaneID As String = "Pane33"

Dim i As Integer = 0
For Each accpane As AjaxControlToolkit.AccordionPane In Accordion1.Panes
If (accpane.Visible = True) Then
If (accpane.ID = strPaneID) Then
Accordion1.SelectedIndex = i
Exit For
End If
i += 1
End If
Next

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.