Solved

State/Province/Country Issue MVC

Posted on 2013-11-28
2
286 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now