Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I add a DropDownList in a Create view populated by a query from another Controller using .NET MVC and C#?

Posted on 2011-02-16
2
Medium Priority
?
453 Views
Last Modified: 2012-05-11
Hello,

I'm very new to .NET, C# and MVC in general, so I'm not quite sure how to handle this simple task...

I'm using MVC 3 and C# with my ASP.NET framework.

I have two Controllers right now.  Say, CarListController.cs and CarMakeController.cs.  I used the built-in 'View' creator to show a List of the Cars that is built in the 'CarList.cs' Model.  This also built a link to the 'Create' page that I then built using this same technique.  

Now, it works great for just typing in the Car Name, Car Model and Car Make, but I would like the Car Make to be a DropDownList that is populated with data from another table that I have.  That table was built using the CarMakeController.cs Controller and CarMake.cs Model.

I would just like to bind a DropDownList to the values in another table in my Database for use on that create page.

Thank you very much in advance and please let me know if you need me to clarify!!!!!!!!!
0
Comment
Question by:stracqan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 34913926
Normally you would do this using a ViewModel that enacapsulates both your Model and options for the dropdown. This tutorial (especially the part about creating the Edit view) shuold point you in the right direction:

    http://www.asp.net/mvc/tutorials/mvc-music-store-part-5
0
 

Author Closing Comment

by:stracqan
ID: 34917835
Thanks!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question