I am getting a list of my users using the below code:
Here is my view:
@model System.Web.Security.MembershipUserCollection
@{
ViewBag.Title = "ManageProfile";
}
<div class ="hero-unit">
<h2>ManageProfile</h2>
<ul>
@foreach (MembershipUser user in Model)
{<li>@user.UserName</li>}
</ul>
</div>
Here is my controller:
public ActionResult ManageProfile()
{
var users = Membership.GetAllUsers();
return View(users);
}
I would prefer that I be able to select the user from a dropdown list. How do I modify my code to yield a dropdown list? (my goal is to be able to select the user from the dropdown list and change details of that user’s profile)
As always in ASP.NET MVC application you could start by designing a view model that will meet the requirements of your view (which from what you described in your question is displaying a dropdownlist with all users):
then you write a controller that will query your repositories and construct a view model that will be passed to the view:
and finally you write a corresponding view: