Hi sallmomar,
Check this example. Now please take its reference and correct your code.
Database
CREATE TABLE [Site]
(
Id INT PRIMARY KEY IDENTITY,
Nom VARCHAR(10),
Marque INT,
Model VARCHAR(10),
Numero VARCHAR(10),
Plage VARCHAR(10)
)
GO
INSERT INTO [Site] VALUES('Nom1', 1, 'fa', 'duo', 'lo')
INSERT INTO [Site] VALUES('Nom1', 2, 'fi', 'da', 'lle')
INSERT INTO [Site] VALUES('Nom1', 3, 'fa', 'di', 'llww')
INSERT INTO [Site] VALUES('Nom2', 4, 'fa', 'du', 'lo')
INSERT INTO [Site] VALUES('Nom2', 5, 'fi', 'da', 'lle')
INSERT INTO [Site] VALUES('Nom3', 6, 'fa', 'di', 'llww')
Controller
public class HomeController : Controller
{
// GET: /Home/
public ActionResult Index()
{
TestEntities db = new TestEntities();
TempData["listesite"] = db.Sites.ToList();
return View();
}
}
View
<table>
<tr>
<th>Nom</th>
<th>Marque</th>
<th>Model</th>
<th>Nuemro</th>
<th>Plage</th>
</tr>
<%foreach (var item in ((List<Site>)TempData["listesite"]).GroupBy(x => x.Nom))
{%>
<tr>
<th><%=item.Key %></th>
<th colspan="4"></th>
</tr>
<%foreach (Site data in ((List<Site>)TempData["listesite"]).Where(x => x.Nom == item.Key))
{%>
<tr>
<td></td>
<td><%=data.Marque%></td>
<td><%=data.Model%></td>
<td><%=data.Numero%></td>
<td><%=data.Plage%></td>
</tr>
<% } %>
<%} %>
</table>
Screenshot