我有一个选项框:
<select name="TypePar" onchange="this.form.submit()">
<option value="0">All Vehicles</option>
<option value="1">Car </option>
<option value="2">Truck</option>
<option value="3">Van </option>
<option value="4">SUV</option>
<option value="5">RV</option>
</select>
我想获得每个选项的总数(可提供14辆车,可提供4辆卡车等)。
我该怎么做?
这是我的控制器:
[HttpPost]
public ActionResult Index(int? TypePar)
{
if (TypePar != 0)
{
var inventorys = db.Inventorys.Include(i => i.CarFeature).Include(i => i.VehicleModel)
.Where(z => z.VehicleModel.TypeId == TypePar);
return View(inventorys.ToList());
}
else
return View();
}
非常感谢!