You can't put a
<div>
directly inside a
<table>
like that. And you're putting every item in its own row.
If you want to use a table, you'll need to put three
<td>
s in each
<tr>
:
<table class="table table-bordered" style="font-size:23px">
<thead>
<tr>
<th colspan="3" style="text-align:center; color:#ffffff; background-color:#2980b9">
Tester
</th>
</tr>
</thead>
<tbody>
@if (ViewBag.TesterUnit is IEnumerable<YourViewModelHere> unit)
{
var rows = unit.Select((item, index) => (item, index))
.GroupBy(r => r.index % 3, (key, items) => items.Select(r => r.item));
foreach (var row in rows)
{
<tr>
@foreach (var item in row)
{
<td>
@Html.ActionLink(item.Name, "UnitDetails", new { id = item.TesterID })
</td>
}
</tr>
}
}
</tbody>
</table>
To use the Bootstrap responsive grid, you'll need to remove the table markup:
<h4 class="text-center" style="color:#ffffff; background-color:#2980b9">Tester</h4>
@if (ViewBag.TesterUnit is IEnumerable<YourViewModelHere> unit)
{
var rows = unit.Select((item, index) => (item, index))
.GroupBy(r => r.index % 3, (key, items) => items.Select(r => r.item));
foreach (var row in rows)
{
<div class="row">
@foreach (var item in row)
{
<div class="col-md-4 border">
@Html.ActionLink(item.Name, "UnitDetails", new { id = item.TesterID })
</div>
}
</div>
}
}
NB: You'll need to replace
YourViewModelHere
with the actual class name.