在ASP.NETCoreMVC中选择Tag Helper在ASP.NETCore中的SELECT标记助手方面,我需要一些帮助。我有一个员工列表,我正试图绑定到一个选择标记助手。我的员工List<Employee> EmployeesList所选择的值将进入EmployeeId财产。我的视图模型如下所示:public class MyViewModel
{
public int EmployeeId { get; set; }
public string Comments { get; set; }
public List<Employee> EmployeesList {get; set; }
}我的雇员班如下所示:public class Employee
{
public int Id { get; set; }
public string FullName { get; set; }
}我的问题是如何告诉选择标记助手使用Id作为显示时的值FullName在下拉列表里?<select asp-for="EmployeeId" asp-items="???" />我希望能帮上忙。谢谢。
3 回答
aluckdog
TA贡献1847条经验 获得超7个赞
// Summary: // Returns a select list for the given TEnum. // // Type parameters: // TEnum: // Type to generate a select list for. // // Returns: // An System.Collections.Generic.IEnumerable`1 containing the select list for the // given TEnum. // // Exceptions: // T:System.ArgumentException: // Thrown if TEnum is not an System.Enum or if it has a System.FlagsAttribute. IEnumerable<SelectListItem> GetEnumSelectList<TEnum>() where TEnum : struct;
- 3 回答
- 0 关注
- 964 浏览
添加回答
举报
0/150
提交
取消