I am using a listview to populate a table with 1000 rows. The DB table is about questions and answers.
I want to use accordion control with listview. Should i put the accordion control inside listview itemtemplate?
What i want is clicking on the 1st question opens the 1st answer and clicking on the 2nd question closes the 1st answer and opens the 2nd answer.
UPDATE:
I am trying it this way
<asp:ListView ID="lvQuestions" runat="server"
DataKeyNames="QueryID"
DataSourceID="SqlDataSourceQueries">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<div id="products">
<h3><a href="#"><asp:Label ID="Label1" runat="server" Text='<%# Eval("Query") %>' ></asp:Label></a></h3>
<div><asp:Label ID="ReplyLabel" runat="server" Text='<%# Eval("Reply") %>'></asp:Label></div>
</div>
</ItemTemplate>
</asp:ListView>
But its not working.
You could use Jquery Accordion
Like in the documentation you would render your rows into the following structure:
Your ListView could look like this:
Codebehind (sorry it’s in C#, but you should be able to translate)
Using the ItemDataBound-Event might look as unneccesary overhead to some guys, but depending on your situation, you might want to have more control about the text being rendered depending on the values in your custom class.