如何使div(<div id="HoverMe">
)可以移动,并显示AllCarId
- 列表中的名称列表(返回Car.Name
代替Car.Id
)?
Owner(Id)
和Car(Id, OwnerId, Name)
。 TotCar
,我在控制器中使用Count()
在Car.OwnerId = Owner.Id
中添加总model.TotCar
。public List<Guid> AllCarId { get; set; }
,以便将OwnerId
传递给每个相关Owner.Id
= Car.OwnerId
的列表。到目前为止,我得到了这个,我目前显示TotCar
的计数值:
<div id="HoverMe">
@Html.DisplayFor(model => model.TotCar)
</div>
@*I want this to be hoverable and list all from AllCarId(convert to name) in a "listbox"*@
那么我如何让<div id="HoverMe">
可以悬停,一旦它悬停,就列出AllCarId
中的每一项?
这就是我将id
传递给控制器中AllCarId
的方法。
List<Guid> GetCarIds = db.Cars.Where(c => c.OwnerId == id).Select(c=> c.OwnerId).ToList();
然后我将GetCarIds
传递给模型public List<Guid> AllCarId { get; set; }
属性。
编辑:模型的相关属性:
视图模型:
public List<Guid> AllCarId { get; set; }
public int TotCar { get; set; }
public virtual Car Car { get; set; }
汽车:
public System.Guid Id { get; set; }
public System.Guid OwnerId { get; set; }
public string Name { get; set; }
拥有者:
public System.Guid Id { get; set; }