Home
Manage Your Code
Snippet: State List with optional Candian provinces (C#)
Title: State List with optional Candian provinces Language: C#
Description: Typically used to bind to a dropdown control Views: 981
Author: Andy Ager Date Added: 3/26/2006
Copy Code  
1  public static SortedList GetStateList(bool includeCanada)
2    {
3
4        SortedList mySortedList = new SortedList();
5        
6        mySortedList.Add(string.Empty, string.Empty);
7        mySortedList.Add("AL", "Alabama");
8        mySortedList.Add("AK", "Alaska");
9        mySortedList.Add("AS", "American Samoa");
10        mySortedList.Add("AZ", "Arizona");
11        mySortedList.Add("AR", "Arkansas");
12        mySortedList.Add("CA", "California");
13        mySortedList.Add("CO", "Colorado");
14        mySortedList.Add("CT", "Connecticut");
15        mySortedList.Add("DE", "Delaware");
16        mySortedList.Add("DC", "District Of Columbia");
17        mySortedList.Add("FL", "Florida");
18        mySortedList.Add("GA", "Georgia");
19        mySortedList.Add("GU", "Guam");
20        mySortedList.Add("HI", "Hawaii");
21        mySortedList.Add("ID", "Idaho");
22        mySortedList.Add("IL", "Illinois");
23        mySortedList.Add("IN", "Indiana");
24        mySortedList.Add("IA", "Iowa");
25        mySortedList.Add("KS", "Kansas");
26        mySortedList.Add("KY", "Kentucky");
27        mySortedList.Add("LA", "Louisiana");
28        mySortedList.Add("ME", "Maine");
29        mySortedList.Add("MH", "Marshall Islands");
30        mySortedList.Add("MD", "Maryland");
31        mySortedList.Add("MA", "Massachusetts");
32        mySortedList.Add("MI", "Michigan");
33        mySortedList.Add("MN", "Minnesota");
34        mySortedList.Add("MS", "Mississippi");
35        mySortedList.Add("MO", "Missouri");
36        mySortedList.Add("MT", "Montana");
37        mySortedList.Add("NE", "Nebraska");
38        mySortedList.Add("NV", "Nevada");
39        mySortedList.Add("NH", "New Hampshire");
40        mySortedList.Add("NJ", "New Jersey");
41        mySortedList.Add("NM", "New Mexico");
42        mySortedList.Add("NY", "New York");
43        mySortedList.Add("NC", "North Carolina");
44        mySortedList.Add("ND", "North Dakota");
45        mySortedList.Add("OH", "Ohio");
46        mySortedList.Add("OK", "Oklahoma");
47        mySortedList.Add("OR", "Oregon");
48        mySortedList.Add("PA", "Pennsylvania");
49        mySortedList.Add("PR", "Puerto Rico");
50        mySortedList.Add("RI", "Rhode Island");
51        mySortedList.Add("SC", "South Carolina");
52        mySortedList.Add("SD", "South Dakota");
53        mySortedList.Add("TN", "Tennessee");
54        mySortedList.Add("TX", "Texas");
55        mySortedList.Add("UT", "Utah");
56        mySortedList.Add("VT", "Vermont");
57        mySortedList.Add("VI", "Virgin Islands");
58        mySortedList.Add("VA", "Virginia");
59        mySortedList.Add("WA", "Washington");
60        mySortedList.Add("WV", "West Virginia");
61        mySortedList.Add("WI", "Wisconsin");
62        mySortedList.Add("WY", "Wyoming");
63
64        if (includeCanada == true)
65        {
66
67            mySortedList.Add("AB", "Alberta");
68            mySortedList.Add("BC", "British Columbia");
69            mySortedList.Add("MB", "Manitoba");
70            mySortedList.Add("NB", "New Brunswick");
71            mySortedList.Add("NL", "Newfoundland and Labrador");
72            mySortedList.Add("NT", "Northwest Territories");
73            mySortedList.Add("NS", "Nova Scotia");
74            mySortedList.Add("NU", "Nunavut");
75            mySortedList.Add("ON", "Ontario");
76            mySortedList.Add("PE", "Prince Edward Island");
77            mySortedList.Add("QC", "Quebec");
78            mySortedList.Add("SK", "Saskatchewan");
79            mySortedList.Add("YT", "Yukon");
80
81        }
82
83        return mySortedList;
84
85    }