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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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