Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7742897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:23:39+00:00 2026-06-01T09:23:39+00:00

I am using a listview to populate a table with 1000 rows. The DB

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:23:41+00:00Added an answer on June 1, 2026 at 9:23 am

    You could use Jquery Accordion

    Like in the documentation you would render your rows into the following structure:

    <div id="accordion">
        <h3><a href="#">First header</a></h3>
        <div>First content</div>
        <h3><a href="#">Second header</a></h3>
        <div>Second content</div>
    </div>
    

    Your ListView could look like this:

    <asp:ListView ID="lvQuestions" runat="server"
        onitemdatabound="lvQuestions_ItemDataBound">
        <LayoutTemplate>
           <div id="accordion">
            <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
           </div>
        </LayoutTemplate>
        <ItemTemplate>
           <h3><a href="#"><asp:Literal ID="litQuestion" runat="server" /></a></h3>
             <div><asp:Literal ID="litAnswer" runat="server" /></div>
        </ItemTemplate>
    </asp:ListView> 
    

    Codebehind (sorry it’s in C#, but you should be able to translate)

    protected void lvQuestions_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        if (e.Item.ItemType == ListViewItemType.DataItem)
        {
            Literal litQuestion = (Literal)e.Item.FindControl("litQuestion");
            Literal litAnswer = (Literal)e.Item.FindControl("litAnswer");
    
    
            YourClass item = e.Item.DataItem as YourClass;
            litQuestion.Text = item.Question;
            litAnswer.Text = item.Answer;
         }
     }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a custom method to populate a ListView control using Generics:
I have a ListView that is populated using an XML file. However, I want
What are the advantages of using listview over gridview? I need pagination, editing rows,
Is there any way creating a photo gallery using Listview control ? Im playing
I'm using the following code to populate listview Oncreate method: SimpleAdapter adapter = new
I am using a listview, and trying to populate using a file. I need
I'm having an issue using a MatrixCursor to populate my ListView : private void
Using the following to populate my ListView with checkbox-supported list: setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, new
I am using an ListAdapter to populate a ListView like this: static final String[]
My Android app needs to populate the ListView using the data from an ArrayList

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.