这是我原本认为可以在任何地方使用的东西。我需要做一个美国所有州的下拉列表。是否有一个C#类对象已经安装了所有设置?
答案 0 :(得分:5)
快速搜索给了我这个:
<select name="State">
<option value="" selected="selected">Select A State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
来源:http://www.geekpedia.com/code55_Drop-down-list-of-US-states.html
这应该可以让你做你需要的事情:
List<SelectListItem> states = new List<SelectListItem>();
states.Add(new SelectListItem { value="" selected="selected", text="Select A State"});
states.Add(new SelectListItem { value="AL", text="Alabama"});
states.Add(new SelectListItem { value="AK", text="Alaska"});
states.Add(new SelectListItem { value="AZ", text="Arizona"});
states.Add(new SelectListItem { value="AR", text="Arkansas"});
states.Add(new SelectListItem { value="CA", text="California"});
states.Add(new SelectListItem { value="CO", text="Colorado"});
states.Add(new SelectListItem { value="CT", text="Connecticut"});
states.Add(new SelectListItem { value="DE", text="Delaware"});
states.Add(new SelectListItem { value="DC", text="District Of Columbia"});
states.Add(new SelectListItem { value="FL", text="Florida"});
states.Add(new SelectListItem { value="GA", text="Georgia"});
states.Add(new SelectListItem { value="HI", text="Hawaii"});
states.Add(new SelectListItem { value="ID", text="Idaho"});
states.Add(new SelectListItem { value="IL", text="Illinois"});
states.Add(new SelectListItem { value="IN", text="Indiana"});
states.Add(new SelectListItem { value="IA", text="Iowa"});
states.Add(new SelectListItem { value="KS", text="Kansas"});
states.Add(new SelectListItem { value="KY", text="Kentucky"});
states.Add(new SelectListItem { value="LA", text="Louisiana"});
states.Add(new SelectListItem { value="ME", text="Maine"});
states.Add(new SelectListItem { value="MD", text="Maryland"});
states.Add(new SelectListItem { value="MA", text="Massachusetts"});
states.Add(new SelectListItem { value="MI", text="Michigan"});
states.Add(new SelectListItem { value="MN", text="Minnesota"});
states.Add(new SelectListItem { value="MS", text="Mississippi"});
states.Add(new SelectListItem { value="MO", text="Missouri"});
states.Add(new SelectListItem { value="MT", text="Montana"});
states.Add(new SelectListItem { value="NE", text="Nebraska"});
states.Add(new SelectListItem { value="NV", text="Nevada"});
states.Add(new SelectListItem { value="NH", text="New Hampshire"});
states.Add(new SelectListItem { value="NJ", text="New Jersey"});
states.Add(new SelectListItem { value="NM", text="New Mexico"});
states.Add(new SelectListItem { value="NY", text="New York"});
states.Add(new SelectListItem { value="NC", text="North Carolina"});
states.Add(new SelectListItem { value="ND", text="North Dakota"});
states.Add(new SelectListItem { value="OH", text="Ohio"});
states.Add(new SelectListItem { value="OK", text="Oklahoma"});
states.Add(new SelectListItem { value="OR", text="Oregon"});
states.Add(new SelectListItem { value="PA", text="Pennsylvania"});
states.Add(new SelectListItem { value="RI", text="Rhode Island"});
states.Add(new SelectListItem { value="SC", text="South Carolina"});
states.Add(new SelectListItem { value="SD", text="South Dakota"});
states.Add(new SelectListItem { value="TN", text="Tennessee"});
states.Add(new SelectListItem { value="TX", text="Texas"});
states.Add(new SelectListItem { value="UT", text="Utah"});
states.Add(new SelectListItem { value="VT", text="Vermont"});
states.Add(new SelectListItem { value="VA", text="Virginia"});
states.Add(new SelectListItem { value="WA", text="Washington"});
states.Add(new SelectListItem { value="WV", text="West Virginia"});
states.Add(new SelectListItem { value="WI", text="Wisconsin"});
states.Add(new SelectListItem { value="WY", text="Wyoming"});