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

  • Home
  • SEARCH
  • 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 7530297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:52:25+00:00 2026-05-30T04:52:25+00:00

I am getting a list of my users using the below code: Here is

  • 0

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)

  • 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-05-30T04:52:27+00:00Added an answer on May 30, 2026 at 4:52 am

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

    public class MyViewModel
    {
        [Display(Name = "select user")]
        public string SelectedUser { get; set; }
        public IEnumerable<SelectListItem> Users { get; set; }
    }
    

    then you write a controller that will query your repositories and construct a view model that will be passed to the view:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var users = Membership.GetAllUsers();
            var model = new MyViewModel
            {
                Users = users.OfType<MembershipUser>().Select(x => new SelectListItem
                {
                    Value = x.UserName,
                    Text = x.UserName
                })
            };
            return View(model);
        }
    
        [HttpPost]
        public ActionResult Index(string selectedUser)
        {
            return Content("Thank you for selecting " + selectedUser);
        }
    }
    

    and finally you write a corresponding view:

    @model MyViewModel
    @using (Html.BeginForm())
    {
        @Html.LabelFor(x => x.SelectedUser)
        @Html.DropDownListFor(x => x.SelectedUser, Model.Users)
        <button type="submit">OK</button>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the code below for getting a list of child processes on windows
I am getting strange behaviour using the built-in C# List.Sort function with a custom
I keep on getting this error error: expected specifier-qualifier-list for core data code im
Below is the list of dict using trying to generate dict data = [
I keep getting a 'List does not exist' error whenever I try and use
I am having a problem getting a list of fields from a query defined
Im iterating a list and getting hold of 2 fields Name and Url i
Why am I getting a textbox that returns undefined list of variables? When I
Lately we've started getting issues with outdated countries / regions list being presented to
I need to display the list of names which I am getting from the

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.