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 5965645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:39:47+00:00 2026-05-22T19:39:47+00:00

So, I found this tutorial that had also the code source of the example

  • 0

So, I found this tutorial that had also the code source of the example showing how to make cascading dropdownlist using Jquery.
I tried to use that code for my own project example but it didn’t seem to work.

    public class IndexViewModel
    {
        //1st DDL ID
        public int grupa_id
        {
            get;
            set;
        }


        //1st DropDownList Values
        public List<SelectListItem> GrupeValues
        {
            get;
            set;
        }

        //2nd  DDL ID
        public int produs_id
        {
            get;
            set;
        }


        //2nd DropDownList Values
        public List<SelectListItem> ProduseValues
        {
            get;
            set;
        }
    }

The Controller.:

    public ActionResult Blabla()
    {
        DataRepository objRepository = new DataRepository();

        IndexViewModel objIndexViewModel = new IndexViewModel();

        objIndexViewModel.GrupeValues = objRepository.GetGrupa();

        //Get the first item of the First drop down list(State ddl)
        string first = objIndexViewModel.GrupeValues[0].Value;

        //Get the City names based on the first Item in the State ddl
        objIndexViewModel.ProduseValues = objRepository.GetProduse(Convert.ToInt16(first));

        return View(objIndexViewModel);
    }

Then the actiont that return jsonresult:

    public JsonResult Cities_SelectedState(int param)
    {
        DataRepository objRepository = new DataRepository();

        JsonResult result = new JsonResult();
        var vCities = objRepository.GetProduse(Convert.ToInt16(param));
        result.Data = vCities.ToList();
        result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
        return result;
    }

The View:

       <script type="text/javascript">
           $(document).ready(function () {
               $("#grupa_id").change(function () {
                   var url = '<%= Url.Content("~/") %>' + "Home/Cities_SelectedState";
                   var ddlsource = "#grupa_id";
                   var ddltarget = "#produs_id";
                   $.getJSON(url, { param: $(ddlsource).val() }, function (data) {
                       $(ddltarget).empty();
                       $.each(data, function (index, optionData) {
                           $(ddltarget).append("<option value='" + optionData.Text + "'>" + optionData.Value + "</option>");
                       });

                   });
               });
           });

   </script>

<p>

  <%:Html.Label("Grupe:") %>
  <%:Html.DropDownListFor(m=>m.grupa_id, Model.GrupeValues) %>

  <%:Html.Label("Produse:") %>
  <%:Html.DropDownListFor(m=>m.produs_id, Model.ProduseValues)%>        
</p>

Where and what am I doing wrong?

  • 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-05-22T19:39:47+00:00Added an answer on May 22, 2026 at 7:39 pm

    You are calling Home/Cities_SelectedState but I don’t see where you pass the int param in — maybe that is what you are missing.

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

Sidebar

Related Questions

I found this tutorial that explains what I want to do using html but
I have just found this great tutorial as it is something that I need.
So I found this: http://tiles.apache.org/framework/tutorial/advanced/nesting-extending.html Here is the example: <definition name=myapp.homepage template=/layouts/classic.jsp> <put-attribute name=title
Below is some html I found in this jquery tooltip tutorial, the contents inside
I found this open-source library that I want to use in my Java application.
I'm running through this tutorial found here: http://vb.net-informations.com/crystal-report/vb.net_crystal_report_from_multiple_tables.htm which teaches how to pass a
Reading this question I found this as (note the quotation marks) code to solve
I am following this tutorial that is like the hello world for post-commit I
I'm using Ubuntu 10, python 2.6.5 I'm following this tutorial: http://www.djangobook.com/en/2.0/chapter02 I followed all
I found this tutorial on how getting Idle time of the user Idle Time

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.