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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:45:09+00:00 2026-05-19T16:45:09+00:00

I am building a screen in my C# Asp.Net MVC application, which has a

  • 0

I am building a screen in my C# Asp.Net MVC application, which has a few related drop downs.So, for example, I select ‘Category’, and then a 2nd drop down should display all related sub categories for the selected category.

So, would the model contain a List, used to build the Category drop down, and then a List, initially empty. On the selection of the category, I need to do a post back, passing back the id if the selected Category, then populate the List<> Sub Categories… and then build the Sub Category drop down?

Hopefully someone can assist with the design of my model. The model would also have quite a few non-list related data for the item being edited. And I think the model would also need a ‘CategorySelectedId’, so that I know what was selected?

  • 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-19T16:45:09+00:00Added an answer on May 19, 2026 at 4:45 pm

    The nicest way is to use AJAX for this. You’ll have to hook the change event to your first select box, and once it is changed, you’ll do a AJAX request with the selected value to some Action. The action will return a JSON list, which will be parsed and put in the next select box.

    Update

    The model for the JSON returning action can be an anonymous type really, or a IEnumerable of SelectListItem. Use Linq: `mycollection.select(item=> new SelectListItem() { Name = item.Name, Value = item.ID.ToString() });

    If we assume the page looks like this:

    <form>
       <select id="MainCat" name="MainCatID">
          <option value="1">First option</option>
          <option value="2">First option</option>
          <option value="3">First option</option>
       </select>
    
       <select id="SubCat" name="SubCatID" disabled="disabled">
          <option value=""> -- Please select a main category -- </option>
       </select>
    </form>
    

    Your model would look like:

    public class MyModel {
        public int MainCatID {get;set;}
        public int SubCatID {get;set;}
        public IEnumerable<SelectListItem> MainCats {get;set;}
    }
    

    Of course you could add validation attributes etc.

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

Sidebar

Related Questions

I am building an asp.net mvc application. I have my top menu structure which
I am building an ASP.NET MVC web application and I'm using jQuery for some
We are building a fairly large HR application in ASP.NET MVC, and so far
Investigating the security of a system I'm building with ASP.NET MVC 2 led me
I'm building a touch screen kiosk application in .NET (C#, WPF). the app itself
Hi I am building a wpf application in which a screen will be comprising
i am building a new web site using asp.net mvc3 web application ,, and
I'm building a rather specialized screen saver application for some kiosks running Windows XP.
I have an iPhone app accessing an ASP.NET Webservice for data. Since I'm building
The app I'm building has to draw around 400 quadrilateral shapes onto the screen

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.