Posted By

krisdb on 10/29/07


Tagged

c


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

tivi
jasonseney
umang_nine
ddevening
madelk
windmarble


dropdown states


 / Published in: C#
 

  1. <asp:DropDownList id="ddlStates" runat="server">
  2. <asp:ListItem Value="">-- Select --</asp:ListItem>
  3. <asp:ListItem Value="AL">Alabama</asp:ListItem>
  4. <asp:ListItem Value="AK">Alaska</asp:ListItem>
  5. <asp:ListItem Value="AZ">Arizona</asp:ListItem>
  6. <asp:ListItem Value="AR">Arkansas</asp:ListItem>
  7. <asp:ListItem Value="CA">California</asp:ListItem>
  8. <asp:ListItem Value="CO">Colorado</asp:ListItem>
  9. <asp:ListItem Value="CT">Connecticut</asp:ListItem>
  10. <asp:ListItem Value="DC">District of Columbia</asp:ListItem>
  11. <asp:ListItem Value="DE">Delaware</asp:ListItem>
  12. <asp:ListItem Value="FL">Florida</asp:ListItem>
  13. <asp:ListItem Value="GA">Georgia</asp:ListItem>
  14. <asp:ListItem Value="HI">Hawaii</asp:ListItem>
  15. <asp:ListItem Value="ID">Idaho</asp:ListItem>
  16. <asp:ListItem Value="IL">Illinois</asp:ListItem>
  17. <asp:ListItem Value="IN">Indiana</asp:ListItem>
  18. <asp:ListItem Value="IA">Iowa</asp:ListItem>
  19. <asp:ListItem Value="KS">Kansas</asp:ListItem>
  20. <asp:ListItem Value="KY">Kentucky</asp:ListItem>
  21. <asp:ListItem Value="LA">Louisiana</asp:ListItem>
  22. <asp:ListItem Value="ME">Maine</asp:ListItem>
  23. <asp:ListItem Value="MD">Maryland</asp:ListItem>
  24. <asp:ListItem Value="MA">Massachusetts</asp:ListItem>
  25. <asp:ListItem Value="MI">Michigan</asp:ListItem>
  26. <asp:ListItem Value="MN">Minnesota</asp:ListItem>
  27. <asp:ListItem Value="MS">Mississippi</asp:ListItem>
  28. <asp:ListItem Value="MO">Missouri</asp:ListItem>
  29. <asp:ListItem Value="MT">Montana</asp:ListItem>
  30. <asp:ListItem Value="NE">Nebraska</asp:ListItem>
  31. <asp:ListItem Value="NV">Nevada</asp:ListItem>
  32. <asp:ListItem Value="NH">New Hampshire</asp:ListItem>
  33. <asp:ListItem Value="NJ">New Jersey</asp:ListItem>
  34. <asp:ListItem Value="NM">New Mexico</asp:ListItem>
  35. <asp:ListItem Value="NY">New York</asp:ListItem>
  36. <asp:ListItem Value="NC">North Carolina</asp:ListItem>
  37. <asp:ListItem Value="ND">North Dakota</asp:ListItem>
  38. <asp:ListItem Value="OH">Ohio</asp:ListItem>
  39. <asp:ListItem Value="OK">Oklahoma</asp:ListItem>
  40. <asp:ListItem Value="OR">Oregon</asp:ListItem>
  41. <asp:ListItem Value="PA">Pennsylvania</asp:ListItem>
  42. <asp:ListItem Value="RI">Rhode Island</asp:ListItem>
  43. <asp:ListItem Value="SC">South Carolina</asp:ListItem>
  44. <asp:ListItem Value="SD">South Dakota</asp:ListItem>
  45. <asp:ListItem Value="TN">Tennessee</asp:ListItem>
  46. <asp:ListItem Value="TX">Texas</asp:ListItem>
  47. <asp:ListItem Value="UT">Utah</asp:ListItem>
  48. <asp:ListItem Value="VT">Vermont</asp:ListItem>
  49. <asp:ListItem Value="VA">Virginia</asp:ListItem>
  50. <asp:ListItem Value="WA">Washington</asp:ListItem>
  51. <asp:ListItem Value="WV">West Virginia</asp:ListItem>
  52. <asp:ListItem Value="WI">Wisconsin</asp:ListItem>
  53. <asp:ListItem Value="WY">Wyoming</asp:ListItem>
  54. </asp:DropDownList>
  55.  
  56. public string SelectedValue
  57. {
  58. get
  59. {
  60. return ddlStates.SelectedValue;
  61. }
  62. set
  63. {
  64. ddlStates.SelectedValue = value;
  65. }
  66. }
  67.  
  68. <asp:RequiredFieldValidator ID="rfvStates" ControlToValidate="ddlStates"
  69. runat="server" EnableClientScript="false" CssClass="validation">*</asp:RequiredFieldValidator>
  70.  
  71. public string id
  72. {
  73. set
  74. {
  75. ddlStates.ID = value;
  76. }
  77. }
  78.  
  79. public string ValidationEnabled
  80. {
  81. set
  82. {
  83. rfvStates.Enabled = Convert.ToBoolean(value);
  84. }
  85. }
  86.  
  87.  
  88. public string ValidationGroup
  89. {
  90. set
  91. {
  92. ddlStates.ValidationGroup = value;
  93. rfvStates.ValidationGroup = value;
  94. }
  95. }
  96.  
  97. public string ValidationErrorMessage
  98. {
  99. set
  100. {
  101. rfvStates.ErrorMessage = value;
  102. }
  103. }
  104.  
  105. public string SelectedValue
  106. {
  107. get
  108. {
  109. return ddlStates.SelectedValue;
  110. }
  111. set
  112. {
  113. ddlStates.SelectedValue = value;
  114. }
  115. }
  116.  
  117.  
  118. public short TabIndex
  119. {
  120. set
  121. {
  122. ddlStates.TabIndex = value;
  123. }
  124. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jasonseney on November 18, 2008

Here's an abbreviated version:

State AL AK AZ AR CA CO CT DC DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VT VA WA WV WI WY

Posted By: jasonseney on November 18, 2008

Ah, (markdown?) stripped the code, trying again:

    State
AL
AK
AZ
AR
CA
CO
CT
DC
DE
FL
GA
HI
ID
IL
IN
IA
KS
KY
LA
ME
MD
MA
MI
MN
MS
MO
MT
NE
NV
NH
NJ
NM
NY
NC
ND
OH
OK
OR
PA
RI
SC
SD
TN
TX
UT
VT
VA
WA
WV
WI
WY
Posted By: jasonseney on November 18, 2008

Forget it, comments won't take code :(

Here's a link to a snippet I made for abbreviated version:

US-States List Abbreviated

You need to login to post a comment.