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
444 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

688 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