'How to dynamically create Dropdownlist by checking on data from 3 tables

I have 3 tables - users, roles and userRoles. Here userId, roleId and userRoleId are their respective primary keys and userRoles table contains foreign key of users and roles. Now in viewbag, I want to show username from user table whose role is project lead from role table. userid and roleId is already in userRoles table for checking. but role table contains multiple roles and I want users only assigned as Project Lead Here is the table structure.enter image description here

Project table contains LeadId which is foreign key for userid of users table. I want to insert userid into leadid through viewbag. How is this possible, any help?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source