Solved

State/Province/Country Issue MVC

Posted on 2013-11-28
2
291 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
2 Comments
 
LVL 8

Accepted Solution

by:
Mohit Vijay earned 500 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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