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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:04:46+00:00 2026-06-15T13:04:46+00:00

I am trying to make a ‘Create New’ page in MVC 4. The page

  • 0

I am trying to make a ‘Create New’ page in MVC 4. The page will have text fields and dropdown fields. I want the items listed in the dropdown box to come from another model.

Main Model: (ignore syntax as following code is a generic example)

public int MainID {get; set;}
public int location {get; set;}
...

someDetails Model:

public int detailID {get; set;}
public int MainID {get; set;}
...
public int actionID {get; set;}

Action Model:

public int actionID {get; set;}
public int location {get; set;}
public string action {get; set;}

SomeDetails carries additional information about Main and is linked by using mainID. I am interested in creating a ‘Add Details’ pages for someDetails. Part of this page will include a dropdown for Action that is based on the location field in main.

What would be the best way to implement the dropdown box? I have a solution that involves passing possible values in the ViewBag, but I’ve seen this labeled bad practice. I was also thinking that it might be possible to change public int actionID {get; set;} to a type of <List>Action. If doing this method, I think I would have the constructor for someDetails populate the list? Would this cause performance issues when simply viewing a particular someDetails since it would try to create the list each time?

Create action:

 public ActionResult Create(int id = -1)
    {
        if (id == -1)
        {
            //NOTE: INSERT REDIRECT HERE
        }
        someDetails model = new someDetails();
        model.MainID = id;
        return View(model);
    }

EDIT:
As requested, better explanation of business logic
The main model I have shown is modeled after an existing table that I am not able to change as it is part of a data warehouse that lives outside my control/group. I am creating an application which allows users to add someDetails in order to gain better visibility/tracking of some of this data. The Action model simply displays possible actions/actionIDs based on the location.

My application will allow a user to search for or filter a set of items from the main model. They will be then allowed to add someDetails which will bring up a form which will contain some text fields and a dropdown list to pick an action. To get possible values for action, I would do something like SELECT * FROM Action a WHERE a.location = currentLocation

  • 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-15T13:04:48+00:00Added an answer on June 15, 2026 at 1:04 pm

    Just create a ViewModel with properties for each model… and that ViewModel can be populated in your controller and then passed to the view.

    EDIT: For DropDownLists:

    In your ViewModel you need a property for the selected action id, and another to the list itself.

    In the model:

    public int actionId { get; set;}
    public SelectList ListOfActions { get; set;}
    //Other model members
    

    In the View:

    @Html.DropDownListFor(model => model.actionId, Model.ListOfActions, "Select one action", new { @class = "yourclass" })
    

    In your controller:

    var model = new YourViewModel();
    model.ListOfActions = new SelectList(this.GetListOfActions(), "ActionName", "ActionId", [here the selected action id in case you need it])  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying make a static text which if too long for the sizer, will
I am fairly new to iOS development and trying make a simple app which
I'm trying make my first python app. I want make simple email sender form.
Trying to make simple jQuery function to create a scrollToTop button that fades in
Trying to make a simple application in rails 3. If I create a team
Trying to make a random password generator in VB.NET So far have got this,
I am trying make a clock. The hour is a string. I want to
in my application I am trying make a requst but i have received an
Trying to make it so my text appears when I roll over the image:
I'm new to wix and trying make an installer for a few dlls. One

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.