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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:02:55+00:00 2026-06-06T00:02:55+00:00

I am reading an enum value from the db then bind it to the

  • 0

I am reading an enum value from the db then bind it to the model. When i post the form with ajax, somehow the enum is unbound or the model property in null or zero but it display properly on the view. I have posted code below. Im using entityframework and mvc3

//model code constructor
public CarModel(Car car)
{
State=(CarState)car.State;
//car.State comes in as an int
//etc setting other variables
}

//CarState property
public CarState {get;set;}

//model code
@Html.DisplayFor(m=>m.CarState)

//Controller code()
Save(CarModel car)
{
//I have code that saves the changes
}

The minute i get to “car”, CarState has no value.

  • 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-06T00:02:59+00:00Added an answer on June 6, 2026 at 12:02 am

    It’s not quite clear how you are passing this value to the controller action. You have only shown some @Html.DisplayFor(m=>m.CarState) but obviously this only displays a label in the view. It doesn’t send anything back to the server. If you want to send some value back you will have to use an input field inside the form.

    For example:

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

    or use a HiddenFor field if you don’t want the user to edit it.

    In any case you need to send that value to the server if you expect the model binder to be able to retrieve it. The model binder is not a magician. He cannot invent values. He binds values to your model from the Request.

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

Sidebar

Related Questions

I'm reading configuration from an xml file. I have a property called linkType in
After reading this old post from Clinton Begin (creator of iBatis) I really wonder
Reading the docs, I'd expect $(#wrap2).remove(.error) to remove all .error elements from #wrap2 .
Here's some code: class myclass { enum STAT { IDLE=0; READING, WRITING, PAINTING, SKATTING
I am currently migrating my code from the old-style enum to enum class. The
I was implenting a TypeList based on Loki, based on reading from: http://aszt.inf.elte.hu/~gsd/halado_cpp/ch06s09.html and
In the post Enum ToString , a method is described to use the custom
I'm using this code for reading socket_.async_read_some(boost::asio::buffer(data_, max_length), boost::bind(&session::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); and this
I'm reading a book about C++. The author shows this enum: [Flags] enum class
When I'm reading Effective Java , the author told me that a single-element enum

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.