我需要一些帮助与选择标签助手在ASP.NET核心。
我有一个员工列表,我正试图将其绑定到一个select tag helper。我的员工在List<Employee> EmployeesList
中,所选值将进入EmployeeId
属性。我的视图模型如下所示:
public class MyViewModel
{
public int EmployeeId { get; set; }
public string Comments { get; set; }
public List<Employee> EmployeesList {get; set; }
}
我的employee类如下所示:
public class Employee
{
public int Id { get; set; }
public string FullName { get; set; }
}
我的问题是,当在下拉列表中显示FullName
时,如何告诉我的选择标记助手使用Id
作为值?
<select asp-for="EmployeeId" asp-items="???" />
如果能帮上忙我会很感激的。谢谢。
https://stackoverflow.com/questions/34624034
复制相似问题