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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:04:07+00:00 2026-06-18T11:04:07+00:00

I have a Employee entity that I’m binding to an Edit view in an

  • 0

I have a Employee entity that I’m binding to an “Edit” view in an MVC3/Razor application. The Employee entity has a property for OccupationTypeId. OccupationTypeId points to the OccupationType table which contains several lookup values. The natural choice would be to use @Html.DropDownListFor to render a <select> tag containing a list of Occupations.

The OccupationType table schema is fairly standard: Id, Name, Description, IsEnabled. Since OccupationTypes can be disabled, I want the OccupationTypeId drop down to still render disabled options so the user can always see their selection if it’s disabled, but a disabled option can’t be selected by the user. In other words, a user can’t change an existing OccupationTypeId to a disabled option.

I thought about creating a @Html extension method to build my <select> tag with the options and simply tack on a disabled attribute to disabled options. I think that would be straight forward…

However, disabled selected options don’t seem to post back to the controller method. In other words, Employee.OccupationTypeId would be null when I post to Edit.

Is there any way to change this behavior or is this built in to MVC 3? I thought about using hidden fields, but what if OccupationTypeId is required and I have validation enabled?

Has anyone else faced this?

Thanks

  • 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-18T11:04:08+00:00Added an answer on June 18, 2026 at 11:04 am

    You could have a hidden field that gets updated when the change event occurs in the dropdown list. This way the OccupationTypeId field is always passed.

    <input name='CurrentOccupationId' type='hidden' value='@Model.Employee.OccupationTypeId' />
    
    <script>
        $(function() {
            $('#dropDownId').change(function() {
                $('input[name="CurrentOccupationTypeId"]').val($(this).val());
            });
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say we have a entity Company that has a to-many relationship to the Employee
Suppose I have employee and department table, employee has foreign key departmentID that is
I have a Department entity which has a one-to-many relationship to an Employee entity.
I have an entity called Route, which has a related entity called Employee: public
I'm using ASP.Net MVC3, and Entity Framework 4. Employee has an OfficeLocation, which is
I have Employee table and an Entity class for it, My task is such
I have class with back reference: public class Employee : Entity { private string
I have an Employee class object that I am calling from my Login.aspx page's
I have two employee lists that I want to get only unique records from
I have an entity in my EDMX that I've extended with a few fields

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.