Razor - add class during first instance of a loop

May 6, 2015 at 9:57 PM
I need to add a class of "in" to the first instance only of a div that appears in my list template's foreach loop.

<div class="item in">
First item in list

<div class="item">
Second item in list

<div class="item">
Third item in list
The actual template for the list is much more complex, so I really want to be able to wrap an if-else statement with an index variable around just the opening div tag, and let the div be closed later in the template. But that doesn't work when I try it.

Is there an easier way?
May 6, 2015 at 10:07 PM
Hi Amanda

Looks like you are looking to create a bootstrap accordeon, here is another thread that discusses it


also i have a sample app with bootstrap tabs, accordeon and carousel, you can find that here


Armand 2DNN
Your friendly non official 2sxc support :)