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 6890923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:20:38+00:00 2026-05-27T06:20:38+00:00

I am trying to create a list manually and then send that over to

  • 0

I am trying to create a list manually and then send that over to the view:

I have the following

    var MyList = new[] {
    new ListEntry {Name = "John Moore"},
    new ListEntry {Name = "Jim Baker"}               

    };

    ViewBag.MyList = new SelectList(MyList , "Name"); 

In the View, I have the following:

    @Html.DropDownListFor(model => model.name.UserName, (IEnumerable<SelectListItem>)ViewBag.MyList)

I was expecting to see John Moore and Jim Baker in the list but instead the list has 2 rows with the following: Digit1.Controllers.ListEntry

Any idea on how I can the list list to show the names. Also when I do a submit, I also need the name to be
updated in the table (ex: John Moore or Jim Baker)

  • 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-27T06:20:38+00:00Added an answer on May 27, 2026 at 6:20 am

    You’re using the wrong overload for SelectList. You need to use the overload that tells it which Display/Value to use:

    new SelectList(myList, "Value", "Name");
    

    Value and Name in this case are the names of the properties on your object that you want to use for the value and display field for your select list.

    The overload you are using is this:

    SelectList(IEnumerable<T> items, object selectedValue)
    

    Basically you are saying your SelectList has “Name” as the selected (default) value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create a list to return some JSON data to a view. Following
I am trying to create a list that adds a new row of data
I have an the following class I'm trying to create a list of with
I'm trying to create a list of tasks that I've read from some text
I'm trying to create a list that some of the elements are defined and
I am trying to create a single-choice (e.g., radio button) list of items that
I'm trying to create a new entity and have it appear in the 'My
I have been trying to create a simple application that will let the user
I'm trying to create a report in Oracle ApEx that displays a list of
I'm trying to create a list that allows me to store multiple instances of

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.