删除下拉列表值

发布于 2024-10-07 23:50:14 字数 834 浏览 1 评论 0原文

我在 MVC2 中工作。这里我有员工屏幕。我本身就有一个下拉列表。所有员工姓名都将加载。我正在查看的员工个人资料不应加载到下拉列表中。我应该从下拉列表中删除特定的员工。这是我加载下拉列表的代码...如何做到这一点...

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;
        }

I am working in MVC2. Here i had Employee Screen. There itself i am having a dropdown list. In that all the Employee Names will loaded. The Employee profile which i am viewing should not be loaded in the dropdown list. I should remove the particular Employee from the dropdown list. Here is my code for loading dropdown...How to do this...

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;
        }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美人迟暮 2024-10-14 23:50:14

RobinHood,

只需将此行:更改

List<EmployeeDetails> managerDetailsList = Employee1.Values.ToList();

为:

List<EmployeeDetails> managerDetailsList = Employee1.Values.Where(x => x.ID != Employee1.ID).ToList();

假设存在这样的属性(ID)。基本上,我所说的是从 managerDetailsList 中排除 Employee1 成员(基于 Employee1.Values 是 IQueryable 的假设)。

RobinHood,

Simply change this line:

List<EmployeeDetails> managerDetailsList = Employee1.Values.ToList();

to:

List<EmployeeDetails> managerDetailsList = Employee1.Values.Where(x => x.ID != Employee1.ID).ToList();

assuming that such an attribute (ID) exists. Basically, what i'm saying is that from the managerDetailsList, exclude the Employee1 member (based on the assumption that Employee1.Values is IQueryable).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文