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
440 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

786 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