R – How to a preselect an item in a List(Of SelectListItem) for DropDownList in ASP.NET MVC VB.NET

asp.net-mvcdrop-down-menu

I have a List(Of SelectListItem) and I fill it with NativeName as .Text and the two letter ISO region name as .Value.

Dim countryList As IList(Of System.Globalization.RegionInfo) = GetRegionInfosForEuOnly()
Dim dropDownCountryList As New List(Of SelectListItem)

For i As Integer = 0 To countryList.Count - 1
  dropDownCountryList.Add(New SelectListItem() With {.Text = countryList(i).NativeName, .Value = countryList(i).TwoLetterISORegionName})
Next

...

<td>
      <%=Html.DropDownList(customerType & "CountryCode", dropDownCountryList)%>*
      <%=Html.ValidationMessage(customerType & "CountryCode")%>
</td>

Now I want to set the RegionInfo for Germany as the preselected Item in the DropDownList.
But

dropDownCountryList.Item(4).Selected = True

doesn't work.

Any Ideas?

Best Answer

How about the use of the SelectList class?