?
Solved

State/Province/Country Issue MVC

Posted on 2013-11-28
2
Medium Priority
?
300 Views
Last Modified: 2013-11-30
Hi:

I have a website with clients from US and Canada.  I've updated the code to MVC and am trying to figure out how have the dropdown for provinces-states populated with the appropriate data depending on the country that was chosen.  

In my forms program, this is what fired when the Country dropdown box changed:

 private void PopulateState_Provinces(string Country_Code)
        {
            if (Country_Code == "US")
            {
                lblProvince.Text = "State:Country";
                lblPostalCode.Text = "Zip Code";
            }
            else
            {
                lblProvince.Text = "Province:Country";
                lblPostalCode.Text = "Postal Code";
            }


            DataTable dtProvinces = DataAccess.Provinces_GetAll(Country_Code);
            drpProv_Code.DataSource = dtProvinces;
            drpProv_Code.DataValueField = "Prov_Code";
            drpProv_Code.DataTextField = "ListName";
            drpProv_Code.DataBind();
        }

Open in new window


Any suggestions greatly appreciated!

RBS
0
Comment
Question by:RBS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Mohit Vijay earned 2000 total points
ID: 39684125
You have to create selectList (that is in MVC)

SelectList selectList = new SelectList(selectListItems, "Value", "Text");

http://www.jimmycollins.org/blog/?p=349
0
 

Author Closing Comment

by:RBS
ID: 39687748
Thanks,

RBS
0

Featured Post

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question