Assuming your list exposes a
Count
property:
@{
int rowCount = ViewBag.listesite.Count;
bool firstRow = true;
}
@foreach (var data in ViewBag.listesite)
{
<tr>
@if (firstRow)
{
firstRow = false;
<th rowspan="@rowCount">@data.Title</th>
}
<td>@data.Marque</td>
<td>@data.Model</td>
<td>@data.Numero</td>
<td>@data.Plage</td>
</tr>
}
EDIT: If there are multiple titles in the list, then group the records:
@{
var allItems = (IEnumerable<YourType>)ViewBag.listesite;
}
@foreach (var group in allItems.GroupBy(i => i.Title))
{
int rowCount = group.Count();
bool firstRow = true;
foreach (var data in group)
{
<tr>
@if (firstRow)
{
firstRow = false;
<th rowspan="@rowCount">@data.Title</th>
}
<td>@data.Marque</td>
<td>@data.Model</td>
<td>@data.Numero</td>
<td>@data.Plage</td>
</tr>
}
}
NB: You'll need to cast the list to a concrete type, since extension methods can't be invoked on
dynamic
values.