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

  • Home
  • SEARCH
  • 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 6113229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:50:06+00:00 2026-05-23T14:50:06+00:00

My requirement is simple, there are two dropdowns in my view. First dropdown is

  • 0

My requirement is simple, there are two dropdowns in my view. First dropdown is filled be default and second dropdown has to be filled based on values from first dropdown.

My view is

<script type='text/javascript'>

$(function() {
    $('#ddlRoles').change(function() {
        $(this).parents('form').submit();
    });
});

< % using (Ajax.BeginForm("UpdateDropdownForm", new AjaxOptions { UpdateTargetId = "txtDropdownValue" }))
{ %>
<%= Html.DropDownList("ddlRoles", (IEnumerable<SelectListItem>)ViewData["RolesData"])%>
<%= Html.DropDownList("ddlUsers", (IEnumerable<SelectListItem>)ViewData["UsersList"])%>

<% } %>

My controller is

public class HomeController : Controller
{       
    public ActionResult Index()
    {
        ViewData["RolesData"] = GetDropdownList();

        List<SelectListItem> usersList = new List<SelectListItem>();
        usersList.Add(new SelectListItem() { Text = "Select" });

        ViewData["UsersList"] = usersList;
        TempData["UsersList"] = usersList;
        return View();
    }

    public IEnumerable<SelectListItem> UpdateDropdownForm(string ddlRoles)
    {
        ViewData["UsersList"] = GetUsersList();
        TempData["UsersList"] = GetUsersList();

        return GetUsersList();            
    }

    public List<SelectListItem> GetDropdownList()
    {
        List<SelectListItem> list = new List<SelectListItem>();

        list.Add(new SelectListItem() { Text = "Admin", Value = "1" });
        list.Add(new SelectListItem() { Text = "Employee", Value = "2" });
        list.Add(new SelectListItem() { Text = "Manager", Value = "3" });

        return list;
    }

    public List<SelectListItem> GetUsersList()
    {
        List<SelectListItem> list = new List<SelectListItem>();

        list.Add(new SelectListItem() { Text = "Administrator", Value = "10" });
        list.Add(new SelectListItem() { Text = "Ramesh", Value = "20" });
        list.Add(new SelectListItem() { Text = "Satish", Value = "30" });

        return list;
    }
}

Here, im able to post the first dropdown data, and im setting the second dropdown data in viewdata/tempdata and in view im binding the data to second dropdown. But this is not working.

For now, when first dropdown is changed, im just binding second dropdown. but what if i want to fill a dropdown and display data in two text boxes. What do i have to do in that case?

How do i solve this.
please help.

  • 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-23T14:50:06+00:00Added an answer on May 23, 2026 at 2:50 pm

    You may find the following answer useful for generating cascading dropdown lists.

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

Sidebar

Related Questions

This is a simple control-flow GOTO question, nothing about resource allocation. There are two
I have a very simple requirement. I have two div. Div1 with a Link
My simple requirement: Reading a huge (> a million) line test file (For this
the Requirement in simple words goes like this. Its a charting Application ( kinda
I have a simple requirement, i need a map of type . however i
I have a simple requirement as mentioned below: A ListView or any control displays
My SQL is rusty -- I have a simple requirement to calculate the sum
I have an ASP ListView, and have a very simple requirement to display numbers
I have a requirement to create a simple database in Access to collect some
I have a requirement to create a simple windows forms application that allows an

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.