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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now