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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:26:43+00:00 2026-06-06T01:26:43+00:00

I have an editor template with a dropdown: @Html.DropDownListFor(m => m.AdmissionState, new List<SelectListItem>() {

  • 0

I have an editor template with a dropdown:

 @Html.DropDownListFor(m => m.AdmissionState, new List<SelectListItem>()
                                                   {
                                                       new SelectListItem()
                                                           {
                                                               Text = "1",
                                                               Value = "1"
                                                           },
                                                       new SelectListItem()
                                                           {
                                                               Text = "2",
                                                               Value = "2"
                                                           },
                                                       new SelectListItem()
                                                           {
                                                               Text = "3",
                                                               Value = "3"
                                                           },                   
                                                   }, "- Select -")

I call it from the view:

@Html.EditorFor(m => m.Licenses)

In controller I have following code:

profile.Licenses.Add(new AttorneyLicenseModel()
        {
            AdmissionDate = "06/14/2012",
            AdmissionState = "2",
            AdmissionNumber = "asd",
        });
        profile.Licenses.Add(new AttorneyLicenseModel()
        {
            AdmissionDate = "07/16/2012",
            AdmissionState = "5",
            AdmissionNumber = "qwe",
        });

For each of the licenses I see the fields with a data populated from the model, but not for the dropdown list – there is default value is checked. What am I doing wrong? ofcourse, the code with values is extremely simlified

  • 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-06-06T01:26:45+00:00Added an answer on June 6, 2026 at 1:26 am

    Try like this:

    @Html.DropDownListFor(
        m => m.AdmissionState, 
        new SelectList(
            new[] 
            {
                new { Value = "1", Text = "1" },
                new { Value = "2", Text = "2" },
                new { Value = "3", Text = "3" },
            }, 
            "Value", 
            "Text", 
            Model.AdmissionState
        ),
        "- Select -"
    )
    

    And if you are interested in understanding why my code works and yours not you could read the following answer I provided yesterday to a similar question: ASP.NET MVC DropDownListFor not selecting value from model

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

Sidebar

Related Questions

I have created an editor template for representing selecting from a dynamic dropdown list
I have the following editor template @model DateTime? @Html.TextBox(, (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty),
I have created a custom editor template for DateTimeOffset: @model DateTimeOffset <div> @Html.LabelFor(m =>
I have this code to set the default value of my select list: public
In my view I call Html.EditFor() which triggers a custom editor-template for this datatype.
I have the following in my Razor view for an editor template in my
I have an editor that built as follows: EditorBuilder builder = context.Html.Telerik().Editor() .Name(ID) .Encode(false)
Hi I have text editor widget in smalltalk (visual works) that returns a text
I have an editor template (Views/Shared/EditorTemplates/HORDER.ascx) which inherits System.Web.Mvc.ViewUserControl<CCOK2.Models.HORDER> My viewmodel has a one-to-many
I have an enumeration in my project and I've created a custom editor template

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.