# Dropdown of users that have a specific role

**URL:** <https://forum.radzen.com/t/dropdown-of-users-that-have-a-specific-role/9201>\
**Category:** Blazor Server\
**Created:** [October 15, 2021, 6:01pm UTC](https://forum.radzen.com/t/dropdown-of-users-that-have-a-specific-role/9201 "2021-10-15T18:01:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Daniel](https://forum.radzen.com/user_avatar/forum.radzen.com/_daniel/32/8520_2.png) [@\_Daniel](https://forum.radzen.com/u/_Daniel)\
**Post date:** [October 15, 2021, 6:01pm UTC](https://forum.radzen.com/t/dropdown-of-users-that-have-a-specific-role/9201/1 "2021-10-15T18:01:45Z")

</div>

I'm trying to get this working with out diving into the IDE too much. (I am fairly new to ef and linq syntax)  
I've got an application with a couple Roles: Admin and Sales Manager.  
In this application there is an Entity called "Store"

When creating a "Store" I would like to be able to select a Sales Manager for that store (which would be a userId on the Store Table). The idea is that only users that have the role of "Sales Manager" would populate in the dropdown field.

Any pointers would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 16, 2021, 8:16am UTC](https://forum.radzen.com/t/dropdown-of-users-that-have-a-specific-role/9201/2 "2021-10-16T08:16:01Z")

</div>

Hi @_Daniel,

This can be achieved with a [custom method](https://www.radzen.com/documentation/blazor/invoke-method/). Add it to the XXX.razor.cs file that Radzen has generated for your XXX page.

```auto
        [Inject]
        public UserManager<ApplicationUser> UserManager { get; set; }

        public async Task<IEnumerable<ApplicationUser>> GetUsers(string role)
        {
            var users = (await Security.GetUsers()).ToList();

            foreach (var user in users)
            {
                user.RoleNames = await UserManager.GetRolesAsync(user);
            }

            return users.Where(user => user.RoleNames.Contains(role));
        }

```

Then invoke this method and set a property to it. This property can then be data-bound to a dropdown.

 ![image](https://forum.radzen.com/uploads/default/original/2X/9/911b71035dad02fe63f0767c8823540e393fd80f.png)

 ![image](https://forum.radzen.com/uploads/default/original/2X/0/0b5c111b1717427dd1eef90de3e11ac2cad702b1.png)  
 ![image](https://forum.radzen.com/uploads/default/original/2X/0/0d4fab0a3c26178e4c0b70eef4e441002a1f7378.png)

---

<div class="post-metadata">

**Author:** ![\_Daniel](https://forum.radzen.com/user_avatar/forum.radzen.com/_daniel/32/8520_2.png) [@\_Daniel](https://forum.radzen.com/u/_Daniel)\
**Post date:** [October 18, 2021, 2:06pm UTC](https://forum.radzen.com/t/dropdown-of-users-that-have-a-specific-role/9201/3 "2021-10-18T14:06:52Z")

</div>

Awesome! This works, one more question, instead of injecting it on every page is there a way to inject it so that it's accessible from any page?
