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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:27:53+00:00 2026-06-07T01:27:53+00:00

I have an entity ProgramType exists in a drop down list when editing the

  • 0

I have an entity “ProgramType” exists in a drop down list when editing the model. If the user doesn’t see what they need in the existing collection, they need to have the ability to add a new entry to that collection on the same editing screen.

Essentially, it seems like I need the same entity to exist twice in the same edit view. If a particular value is selected for the drop down menu, then a text field does a jQuery “show” to allow them to add new data.

 <div class="editor-label">
            @Html.LabelFor(model => model.ProgramTypeId, "Program Type")
        </div>
        <div class="editor-field">
            @Html.DropDownList("ProgramTypeId", "- Select a Program Type - ")
            @Html.ValidationMessageFor(model => model.ProgramTypeId)
        </div>

//this div is hidden via jQuery unless needed

        <div class="editor-label hiddenDiv">
            @Html.Label("New Program Type Title:")
        </div>
        <div class="editor-field hiddenDiv">
            @Html.EditorFor(model => model.ProgramType.ProgramType)
            @Html.ValidationMessageFor(model => model.ProgramType.ProgramType)
        </div>
//
        <div class="editor-label">
            @Html.LabelFor(model => model.ProgramYear)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ProgramYear)
            @Html.ValidationMessageFor(model => model.ProgramYear)
        </div>

What is the best way to achieve this? I’m really tempted to just use the form collection, but that seems like it might be “poor practice”.

public class SurveyProgramModel
    {

        [Key]
        public int ProgramId { get; set; }

        [DisplayName("Year")]
        public int ProgramYear { get; set; }

        [DisplayName("Status")]
        public int ProgramStatusId { get; set; }

        [DisplayName("Program Title")]
        public string ProgramTitle { get; set; }

        public int ProgramTypeId { get; set; }

        [DisplayName("Program Type")]
        public virtual SurveyProgramTypeModel ProgramType { get; set; }

        [DisplayName("Status")]
        public virtual ProgramStatusModel ProgramStatusModel { get; set; }

        public virtual ICollection<SurveyResponseModel> SurveyResponseModels { get; set; }


    }




public class SurveyProgramTypeModel
    {

        [Key]
        public int ProgramTypeId { get; set; }

        [DisplayName("Program Type")]
        public string ProgramType { get; set; }


    }
  • 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-07T01:27:55+00:00Added an answer on June 7, 2026 at 1:27 am

    One approach would be to modify your view model to contain e.g.

    public IEnumerable<SelectListItem> ProgramTypes { get; set; }
    public int SelectedProgramType { get; set; }
    public string NewProgramType { get; set; }
    

    In your controller action, populate ProgramTypes with the list of possible values from your persistence layer, plus an extra value of “Add new…”.

    In your view you can then render your dropdown as

    @Html.DropDownListFor(m => m.SelectedProgramType, Model.ProgramTypes)
    

    Then add some jQuery to show and hide a <div> based on the selected value. Inside this <div> add

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

    And in your [HttpPost] action method add logic to determine if they are adding a new value then save the new value to your persistence layer.

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

Sidebar

Related Questions

I have an Entity result of List<string> GetTagsData that I need to somehow bind
Simple question. I have entity Customer in my edmx model. I need to get
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A
In my business model I have Entity class (IPoint interface ) that has a
I have entity User with one-to-many relationship to UserToUserCategories. When I load user from
I have Entity Data Model using ADO.NET Entity Data Model (using auto generate from
I have entity class which is used to model a weather station, and it
I have entity fluently mapped to existing oracle view: public class MyEntityMap : ClassMap<MyEntity>
I have Entity type class(Serializable, loaded and saved data at runtime) where user specified
I have one entity object (kind) for storing all information from user's advertisement. It

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.