如何排序与数据库无关的下拉列表货币列表项?

How to sort dropdownlist Currency List item that not related with database?

如何在货币列表中对下拉列表进行升序排序。是否需要datatable/dataview?

   For Each cultureInfo__1 As CultureInfo In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
        Dim regionInfo As New RegionInfo(cultureInfo__1.LCID)
        If DrpCurrency.Items.FindByValue(regionInfo.ISOCurrencySymbol) Is Nothing Then
            DrpCurrency.Items.Add(New ListItem(regionInfo.ISOCurrencySymbol + "" + regionInfo.CurrencySymbol))

        End If
    Next

此处输出:

curr.png

因为您需要数据子集,所以您需要构建一个货币符号列表并对其进行排序。

Dim currencyList As List(Of String) = New List(Of String)

For Each cultureInfo As CultureInfo In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
    Dim regionInfo As RegionInfo = New RegionInfo(cultureInfo.LCID)
    If Not currencyList.Contains(regionInfo.ISOCurrencySymbol) Then
        currencyList.Add(regionInfo.ISOCurrencySymbol)
    End If        
Next

DropDownList1.DataSource = currencyList.OrderBy(Function(k) k)
DropDownList1.DataBind