开发者

Remove Dropdownlist Value

开发者 https://www.devze.com 2023-01-30 11:45 出处:网络
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

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开发者_C百科 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;
        }


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消