Using Culture Info Class In ASP.NET Using VB.NET
The CultureInfo class contains culture-specific information, such as the language, country/region, calendar, and cultural conventions.
CultureInfo class
The CultureInfo class from the System.Globalization namespace. The CultureInfo class contains culture-specific information, such as the language, country/region, calendar, and cultural conventions. The CultureInfo class specifies a unique name for each culture. you can set the Culture property of the page.
<%@ Page Language="vb" Culture="en-US" %>
If you run the example now, you will get the output "English (United States)", which is the language of English, with a specific US culture.
GetCultures method
GetCultures method to retrieve a complete list of all cultures.
.ASPX code
Now taking a DropDownList control on the form.
<div>
<span><strong>Select Country :</strong></span>
<asp:DropDownList ID="ddl" runat="server" BackColor="#3399FF"
ForeColor="#66FF66">
</asp:DropDownList>
</div>
Now call this GetCountry method on your page load that will bind and display countries in the DropDownList.
Imports System.Globalization
Public Class WebForm1
Inherits System.Web.UI.Page
Public Function GetCountry() As List(Of String)
Dim list As New List(Of String)()
Dim cultures As CultureInfo() = CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures Or CultureTypes.SpecificCultures)
For Each info As CultureInfo In cultures
Dim info2 As New RegionInfo(info.LCID)
If Not list.Contains(info2.EnglishName) Then
list.Add(info2.EnglishName)
End If
Next
Return list
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ddl.DataSource = GetCountry()
ddl.DataBind()
ddl.Items.Insert(0, "Select")
End Sub
End Class
Now run the application and test it. This will show all the country that are bind with DropDownList.
