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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:15:02+00:00 2026-06-11T18:15:02+00:00

I m using Entity Framework, and have one view which is strongly type view

  • 0

I m using Entity Framework, and have one view which is strongly type view model of type tblAuthorMaster. On Post ModelState returns me following error :


The value '0' is not valid for Status.

Here Status is of boolen datatype in DB/EF and on view it’s dropdown (TEXT=”active/inactive”, VALUE=”1/0″), so whenever i post my form i used to get the above error message.

I have tried some solution to overcome with this issue but it seems not wotking properly.

Following is my code base:

Here tblAuthorMaster is EF Class and AuthorModel is my Custom Class, which i m using for some custom validation and other stuff.


    [MetadataType(typeof(AuthorModel))]
    public partial class tblAuthorMaster { }

    public class AuthorModel
    {
        [Required(ErrorMessage = "*")]
        public string AuthorName { get; set; }
        [Required(ErrorMessage = "*")]
        public bool Status { get; set; }        

    }

Thanks in advance.

  • 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-11T18:15:03+00:00Added an answer on June 11, 2026 at 6:15 pm

    For this to work properly the VALUE in the dropdown must be true/false and not 1/0. Since you haven’t shown how you are generating your doropdown it is hard to help but it might look something like this:

    <%= Html.DropDownListFor(
        x => x.Status,
        new[] 
        {
            new SelectListItem { Value = "true", Text = "active" },
            new SelectListItem { Value = "false", Text = "inactive" },
        }
    ) %>
    

    Also what’s the point of using a dropdown with 2 possible values? HTML provides you with checkboxes for this purpose:

    <%= Html.CheckBoxFor(x => x.Status) %>
    

    And a final remark: what you call a view model in your question is not a view model at all. It’s an autogenerated EF domain model. View models are classes tat you specifically design for the requirements of a given view, they are not autogenerated by some wizard.

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

Sidebar

Related Questions

I have developed an ASP.Net (VB.Net) website which is using Entity Framework and SQL
I have an ASP.NET Dynamic Data application (using Entity Framework) in which I have
I have created a very simple Entity Framework 4.0 model using VS2010 Professional. Ignore
I'm using Entity Framework 4 and have a one-to-many relationship between a parent and
I'm using entity framework 4. I have a stored procedure that just updates one
I am using Entity Framework and I have two tables, a contact relationship table
I'm using Entity Framework and I have a custum IQueryProvider. I use the Execute
I am using Entity Framework 5 RC and i have some code that require
I'm using Entity Framework Code First v 4.3.0 I have a two entities with
I have created a new application using Entity Framework 4.3 database migrations. The migrations

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.