Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:17:58+00:00 2026-06-01T13:17:58+00:00

I have created two dropdownlist, what i am trying to do is make them

  • 0

I have created two dropdownlist, what i am trying to do is make them cascade. Such that the second one is dependent on the first. The reason is because my database is laid out like this

****Car_iD      Car_Name            Car_drive** 
      1           Honda             2 wheel drive
      2           Acura             4wheel drive        
      3           Toyota            2 wheel drive
      4           Honda             4wheelDrive       

As you can see I have two Car_Names that are the same but the Car_drive is different. So when the user clicks on the first dropdown list they will see Honda, Acura, Toyota…but if they select Honda the second dropdown box would say 2wheeldrive and 4wheeldrive.

My Controller looks likes this:

 public ActionResult Home()
  {
  ViewData["Car_Name"] = new SelectList(_context.Cars.Select(a => a.Car_Name).Distinct());
   ViewData["Car_drive"] = new SelectList(_context.Cars.Select(a => a.Car_drive).Distinct());
  }

My View looks like this

      Choose an Car
               <label for= "Car_Names"></label>
                <%= Html.DropDownList("Car_Name" )%>  

               <label for= "Application_Names"></label>
                <%= Html.DropDownList("Car_drive")%>    
                <input type = "submit" value ="Update" /> 
                 <% using(Html.BeginForm("Home", "Home")) { %>  
                <%}%>       

I have read through so many tutorial but nothing really comes close. I got close on the MVC Awesome stuff but I kept getting errors saying SelectableItem is missing a references. Any help on getting this implemented would be great.

update
I have added this to my controller

    public ActionResult CarNameChange(string Car_Name)
    {
        var car_drive = from env in _context.Cars
                              where env.Car_Name == Car_Name
                              select car_drive;
        return Json(ViewData["Car_Drive"] = car_drive); 
    }

Now need some help writing the script to get this information from the controller.

   <script type = "text/javascript">
   $('#Car_Names').change(function(){
      var selectedName = $(this).val();
       $getJson('@Url.Action("
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:18:00+00:00Added an answer on June 1, 2026 at 1:18 pm

    Check: http://blogs.msdn.com/b/rickandy/archive/2012/01/09/cascasding-dropdownlist-in-asp-net-mvc.aspx and http://msprogrammer.serviciipeweb.ro/2011/02/13/asp-net-mvc-jquery-and-razor-cascading-dropdown-retrieving-partial-views-json-send-objects-handling-errors/ and you won’t need anything else. Both projects have a demo to download to inspect code.

    Regards

    EDIT: After your update

    Don’t use ViewData or ViewBag. Make a ViewModel containing properties for Cars and CarDrive it’s cleaner and easier to add something new.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two viewController classes such that one is superclass of another.i have
I have created two forms in my Windows Application. One Form acts as a
I have created two JavaScript files. One file is "validators.js" and the other is
I have created two custom controls. On the basis of features any one of
I have created two functions that sum and subtract the numeric values of two
I have created a customer c# DropDownList control that can render out it's contents
i have created two color layers and displayed them on the screen: if( (self=[super
I have created two views on a FrameLayout, and requested focus to second. When
have created a map that I'm trying to have function similar to 'My Maps'.
I have created a web application in mvc3 and created two partial views one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.