我在MVC2工作。在这里我有员工屏幕。我自己有一个下拉列表。因为所有员工姓名都将被加载。我正在查看的员工配置文件不应加载到下拉列表中。我应该从下拉列表中删除特定的Employee。这是我加载下拉列表的代码...如何做到这一点...
Dictionary<string, Employee> Employee1 = new Dictionary<string, EmployeeDetails>();
Employee1 = EmployeeProxy.GetPrimaryEmployeeList(UserIdentity.TenantID);
List<EmployeeDetails> managerDetailsList = Employee1.Values.ToList();
if (managerDetailsList != null && managerDetailsList.Count > 0)
{
managerDetailsList.Sort(delegate(EmployeeDetails p1, EmployeeDetails p2) { return p1.FirstName.CompareTo(p2.FirstName); });
}
foreach (EmployeeDetails employeedetails in managerDetailsList)
{
employeedetails.FirstName = employeedetails.FirstName + " " + employeedetails.LastName;
}
答案 0 :(得分:1)
罗宾汉,
只需更改此行:
List<EmployeeDetails> managerDetailsList = Employee1.Values.ToList();
为:
List<EmployeeDetails> managerDetailsList = Employee1.Values.Where(x => x.ID != Employee1.ID).ToList();
假设存在这样的属性(ID)。基本上,我所说的是来自managerDetailsList,排除Employee1成员(基于Employee1.Values是IQueryable的假设)。