collapse all and expand all using bootstrap and jquery

Hi All,

I need to display set of comments from Database in one of my asp.net web forms.
I need to display the comment on the click of down arrow. Once the comment is shown the arrow should be changed to up arrow. Clicking the up arrow will hide the comment and changes itself to down arrow.

I need to do this dynamically in C# and asp.net because the comments, username and entrytime are retrieved from database into datatable. so for every row in the datatable I need to create a div with its inner html set for above effect. I also need to have expand all and collapse all links where the first will show all comments and collapse all will hide all comments.

using bootstrap I tried doing some of it in jsfiddle. The link is here.
http://jsfiddle.net/9h2bgndg/12/ 

I have no clue how to do expand all and collapse all. Your help is appreciated.
JyozealAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
This should do what you want
<!doctype html>
<html>
<head>
<title>Test</title>
<link href="css/bootstrap.css" rel="stylesheet" />
<style type="text/css">
h4 a:after {
    font-family:'Glyphicons Halflings';
    content:"\e114";
    float: right;
    color: grey;
}
h4 a.collapsed:after {
    content:"\e080";
}
</style>
</head>
<body>
  <div class="container">
    <div class="row">
      <div class="col-lg-6">
        <h4><a data-parent="form-accordian" data-toggle="collapse" class="collapsed" href="#demo">user abc added a comment - 18/May/15 1:54 PM</a></h4>
        <div class="collapse in" id="demo"> These comments are loaded from the database and hence should be created dynamically</div>      
        <h4><a data-parent="form-accordian" data-toggle="collapse" class="collapsed" href="#demo1">user xyz added a comment -8/april/15 1:54 PM </a></h4>
        <div class="collapse" id="demo1"> This needs to be multiline comment that will be around 4to 5 sentences long. This shoould be shown only when the collapse down arrow is clicked and the collapse down arrown should change to collapse-up. when collapse -up is clicked The comment should hide and collapsible up should be changed to collapsible down</div>        
      </div>
    </div>
  </div>
<script src="http://code.jquery.com/jquery.js"></script>

<!-- Latest compiled and minified JavaScript -->
<script src="js/bootstrap.js"></script>
<script type="text/javascript">
</script>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JyozealAuthor Commented:
Thanks for the answer. This is what I am looking for.
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.