在哪里可以找到用简码定义的美国所有州的类?

发布于 2024-12-05 01:37:02 字数 59 浏览 0 评论 0原文

我本以为这是随处可见的东西。我需要制作美国所有州的下拉列表。是否有一个 C# 类对象已经完成了所有设置?

This is something I would have thought is available everywhere. I need to do a drop-down list of all US states. Is there a C# class object somewhere that already has it all setup?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雄赳赳气昂昂 2024-12-12 01:37:02

快速搜索给了我这个:

<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"});

A quick search gave me this:

<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>

source: http://www.geekpedia.com/code55_Drop-down-list-of-US-states.html

This should allow you to do what you need:

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"});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文