views:

801

answers:

1

So I'm amending someone else's code, and they've used a data-bound Accordion control. I need to disable the Accordion functionality so that the top item is expanded and the rest are just minimized and kept that way.

Also is there any way to put a class on the final item?

Thanks a lot in advance.

+2  A: 

The easiest thing might be to replace the Accordion control with a Repeater that is styled to look like the current Accordion.

But, to attempt to answer your question(s):

Create a OnItemCommand event handler that just sets the SelectedIndex to 0. That way the user can't open any other items in the Accordion.

As far as the style of the final item, you'll have to create a OnItemDataBound event handler that knows how may items are in your collection, and then count the items that it has bound. When the method is binding an item with the index that matches the size of the collection you just set the item's CssClass to be the class for the final item. (This same technique should also work if you were to replace the Accordion with another control.)

Check the first answer for the question 'How do I bind an ASP.net ajax AccordionPane to an XMLDatasource?' for a example of the ItemDataBound event handler.

PhillFox