0
<table border="1" cellpadding="10">
@foreach (var device in @Model.Devices)
{
<tr>
<td>@device.DeviceID</td>
<td>@device.DeviceName</td>
<td>@device.CALs</td>
<td align="right">@device.UnlockedFrom.ToShortDateString()</td>
<td align="right">@device.UnlockedTo.ToShortDateString()</td>
<td>
<a asp-action="DeleteDevice"
asp-controller="Manage"
asp-route-id="@device.DeviceId">
Delete
</a>
</td>
</tr>
}
<td>@device.DeviceID</td>
是好的,但asp-route-id="@device.DeviceId
给人一种波浪device does not contain a definition for DeviceId
视图模型公开设备的集合
public IEnumerable<Device> Devices { get; set; }
Device
包括以下属性
public int DeviceID { get; set; }
public string UserId { get; set; }
public virtual ApplicationUser User { get; set; }
public int CALs { get; set; }
public string DeviceName { get; set; }
public DateTime UnlockedFrom { get; set; }
public DateTime UnlockedTo { get; set; }
怎样使DeviceId
可传递给控制器?
谢谢@Shyju。我真是个白痴! – Vague