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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:20:05+00:00 2026-05-12T05:20:05+00:00

I have a set of drop down controls on a view that are linked

  • 0

I have a set of drop down controls on a view that are linked to two lists.

//control
ViewData["Countries"] = new SelectList(x.getCountries().ToList(), "key","value",country);
ViewData["Regions"] = new SelectList(x.getRegions(country).ToList(), "id", "name", regions);

/*
on the view
*/

<% using (Html.BeginForm("","", FormMethod.Get))
           { %>
           <ol>
               <li>
                <%= MvcEasyA.Helpers.LabelHelper.Label("Country", "Country:")%>
                <%= Html.DropDownList("Country", ViewData["Countries"] as SelectList) %>
                <input type="submit" value="countryGO" class="ddabtns" />
               </li>
               <li>
                <%= MvcEasyA.Helpers.LabelHelper.Label("Regions", "Regions:")%>
                <%= Html.DropDownList("Regions", ViewData["Regions"] as SelectList,"-- Select One --") %>
                <input type="submit" value="regionsGO" class="ddabtns" />
               </li>
           </ol>     
                <br />
                <input type="submit" value="go" />
<% } %>

So its sending a query to the same page (as its only really there to provide an alternative way of setting/updating the appropriate dropdowns, this is acceptable as it will all be replaced with javascript).

The url on clicking is something like…

http://localhost:1689/?country=FRA&regions=117

Regions is dependent on the country code.

I’m trying to achieve this bit without bothering with routing as there’s no real point with regards this function.

So the Controller has the following method.

public ActionResult Index(string country, int regions)
  • 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-12T05:20:05+00:00Added an answer on May 12, 2026 at 5:20 am

    The string should be ok, as it’ll get passed as an empty string. For int, make it nullable:

    public ActionResult Index(string Country, int? Regions)
    

    Also, you’ll note I capitalized it in the same was as your querystring.

    Edit

    Note that ASP.NET now allows you to define default parameters. E.g.:

    public ActionResult Index(string Country, int Regions = 2)
    

    However, IMHO I’d recommend that you only use the default where it makes semantic sense. For example, if the purpose of the Regions parameter were to set the # of regions in a country, and most countries have 2 regions (North and South) then setting a default makes sense. I wouldn’t use a “magic number” that signifies a lack of input (e.g., 999 or -1) — at that point you should just use null.

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

Sidebar

Related Questions

Say that I have a web user control that has several drop down lists
I have a page that has two drop down lists on it and a
I have created a partial view to handle drop down list controls. In my
I have several user controls that contain a drop down list, various validation controls,
Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have
I have custom control with two textboxes and one drop down list. I want
So I have two filtering objects. One is a drop down list, which chooses
1) I have a ReportViewer control on a page that's linked to a ServerReport
In my aspx page, I have a number of drop down controls. I would
If redis gets overloaded, can I configure it to drop set requests? I have

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.