I need to build an HTML code structure in C# code behind. The code inserted an HTML item that occupies 3 columns in a 12 columns Row (I'm using Zurb Foundation).
I iterate over over a collection of items in a foreach loop.
I want to add a <div class='row'>[item html code here]</div>
code that will wrap the 3 column items.
Item code is something like this:
<div class='column large-4 medium-4- small-12' >some content</div>
What logic should I use (C#) in order to be able to inject the item HTML code inside the row code every three items?
My complications start when I need to separate the opening tags (<div class='row'>
) with the closing tag (</div>
) and put the items codes (the column divs) inside.
Assume large number of items that needs to iterate over.
The results html should look something like this if for example I have 7 items:
<div class='row'>
<div class='column large-4'>item 1</div>
<div class='column large-4'>item 2</div>
<div class='column large-4'>item 3</div>
</div>
<div class='row'>
<div class='column large-4'>item 4</div>
<div class='column large-4'>item 5</div>
<div class='column large-4'>item 6</div>
</div>
<div class='row'>
<div class='column large-4'>item 7</div>
</div>
Aucun commentaire:
Enregistrer un commentaire