I want to display the data of the table according to the field Nom chosen on a combobox list.
For example, the combobox list contains Nom1, Nom2, Nom3. If we choose on the list combobox Nom1 we must have only the records related to Nom1
View
@Html.DropDownList("Lsite", new SelectList(Enumerable.Empty<site>(), "Code", "Nom"),
"Select Site", new { @class = "form-control", id = "Lsite" })
<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 (var 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_serie</td>
<td>@data.Plage</td>
</tr>
}
}
</table>
Controller
public ActionResult Index()
{
TestEntities db = new TestEntities();
TempData["listesite"] = db.Site.ToList();
return View();
}