I am populating my datatable using a foreach loop, I would like each iteration to output 2 rows.

I am populating my datatable using a foreach loop, I would like each iteration to output 2 rows.

subrimnrsubrimnr Posts: 1Questions: 1Answers: 0
edited November 2018 in Free community support

My code is
<table class="table table-striped table-responsive" id="myDataTable">
<thead>
<tr>
<td>Question</td>
<td>Answer</td>
</tr>
</thead>

@foreach (var item in Model)
{
    <tr>
        <td>@item.SubStandardName</td>
        <td></td>
    </tr>
    <tr>
        <td>Test</td>
        <td></td>
    </tr>

}

<tfoot>
    <tr>
        <td>Question</td>
        <td>Answer</td>
    </tr>
</tfoot>

</table>

The output is as follows

Question Answer
Fire Defence Organisation
Housekeeping
Liquified Petroleum Gas (LPG) Installations
Test
Test
Test
Question Answer

I would like the output to be
Question Answer
Fire Defence Organisation
Test
Housekeeping
Test
Liquified Petroleum Gas (LPG) Installations
Test
Question Answer

Removing the datatable gives me this output

Please assist

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @subrimnr ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.