Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8009273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:23:49+00:00 2026-06-04T18:23:49+00:00

within a form I have two listbox controls these controls are used for mapping

  • 0

within a form I have two listbox controls these controls are used for mapping users to a role. Within the listbox on the left(available users) I need to show a list of all users associated to the current department. The listbox on the right displays a list of users from the department that are already mapped to the role.
enter image description here

Each listbox is mapped to it’s own collection. What I would like to do is to filter out the names that may appear in the mapped users collection from the available users collection when the listbox initially loads. In looking at the illustration the listbox on the right should only display 1 available user for mapping to this role (In the illustration it would be alguser4)

My inital thought was to create a new collection (avaialbleuserscoll) and attempt to filter using linq. Where I am stuck is a user may be mapped to multiple roles therefore I can’t take the current approach and just test for a count = 0. What I need to do is to test to ensure that the count is == 0 or that the role id does not equal the current roleid.

I’d appreciate any guidance on how to get only users that are not mapped to the current role to display in the listAllUsers listbox

 private void EditMappedUserDetails(int agencyid, int roleid)
    {
        List<SecurityUser> allUserColl;
        List<SecurityUser> mappedUserColl;
        List<SecurityUser> availableUserColl;
        allUserColl = AdminFactory.GetUsersAndRoles(agencyid).OrderByDescending(n => n.UserName).ToList();

        mappedUserColl = SelectedRoleData.FirstOrDefault().SecurityUserRoles.Select(r => r.SecurityUser).OrderByDescending(n => n.UserName).ToList();

        availableUserColl = allUserColl.Except(mappedUserColl).ToList();

        listAllUsers.DataTextField = "UserName";
        listAllUsers.DataValueField = "SecurityUserId";

        listMappedUsers.DataTextField = "UserName";
        listMappedUsers.DataValueField = "SecurityUserId";

        listAllUsers.DataSource = availableUserColl;
        listMappedUsers.DataSource = mappedUserColl;
        listAllUsers.DataBind();
        listMappedUsers.DataBind();
        editUserUpdatePanel.Update();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:23:52+00:00Added an answer on June 4, 2026 at 6:23 pm

    you can use the except function in linq to remove duplicates here is an example

     var m = availableUserColl.Except(mappedUserColl).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a control which is mounted within a form. I need to implement
I have a listbox in a form, and based on the answers within I
Say I have one full-page form, but within the form, there are two or
We have a Modal Window with a contact form within it. We have two
I have a scenario where I need to include an ajax form within another
I am using a windows form and within the form i have a user
I have a form within an ASP.NET MVC application and I'm trying to submit
I have a complex input form within a PHP based web application. To structure
I have a list within Sharepoint, using a custom new form I have added
I have run into an issue where an input field within a form I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.