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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:00:49+00:00 2026-06-05T15:00:49+00:00

I have a DropDownList that contains the correct items and values when the view

  • 0

I have a DropDownList that contains the correct items and values when the view is rendered but the selected value is not being saved within the designated entity field Garage. Currently the value being saved and returned is 0 (None) in both create or edit post methods. I’m sure this is something simple but I can’t figure it out… Thanks in advance!

The Model Class:

public enum GarageType { None = 0, One = 1, Two = 2, Three = 3, Four = 4 }

public int Garage { get; set; }

[NotMapped]
public GarageType GarageEnumValue
{
    get { return (GarageType)Garage; }
    set{ Garage = (int)value; }
}

The Control Create and Edit methods both look like this:

var statuses = from Property.GarageType s in Enum.GetValues(typeof(Property.GarageType))
                       select new { ID = (int)s, Name = s.ToString() };
ViewBag.GarageId = new SelectList(statuses, "ID", "Name", statuses.FirstOrDefault().ID);

Last the View:

@Html.DropDownList("GarageId", String.Empty)
  • 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-05T15:00:51+00:00Added an answer on June 5, 2026 at 3:00 pm

    Use the following overload of DropDownList method

    @Html.DropDownList("GarageEnumValue", (SelectList)ViewBag.GarageId, String.Empty)
    

    If you have a strongly type model use

    @Html.DropDownListFor(m => m.GarageEnumValue, (SelectList)ViewBag.GarageId, String.Empty)
    

    The first argument in both cases should be the property that you are going to bind the list.

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

Sidebar

Related Questions

I have an ASP.NET dropdownlist called #ddlDateRange that contains several items. Possible values in
I have an object that contains a collection of items, each item being another
i have the following view that contains an @Html.DropDownList :- <fieldset> <legend>Answer here</legend> <div
I have a dropdownlist that has 4 columns but only 3 are 'visible' the
I have a dropdownlist that is being populated by a sql server, I am
I have a DropDownList called (DDL) in ASP.net page, I want that DDL contains
I have a field in the table that contains this value American|African|Asian. I want
I have the following code in a custom user control that contains a DropDownList
I have got a requirement to bind a dropdownlist using db values.I gave that
I have a CompositeControl that contains a DropDownList. I have set the AutoPostBack property

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.