To Get all country name in a dropdown

Go down To Get all country name in a dropdown

Post  Admin on Mon Feb 08, 2010 2:27 pm

To Get all country name in a dropdown list in to create a registration form:

You have to take a dropdown list called "cbocountry"

Code are as follows:

Imports System.Globalization
Partial Class _Default
Inherits System.Web.UI.Page
Dim f_Value As String
'Protected WithEvents cboCountry As System.Web.UI.WebControls.DropDownList
Private Function first_load() As String
Dim ci As CultureInfo
Dim str As String
Dim intPos As Integer
Dim intPosDefault As Integer
For Each ci In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
str = ci.DisplayName
intPosDefault = InStr(str, "(")
str = Mid(str, intPosDefault + 1, Len(str) - intPosDefault - 1)
intPos = InStr(str, "(")
If intPos > 0 Then
str = Mid(str, intPos + 1, Len(str) - intPos)
End If
If cboCountry.Items.Count > 0 Then
Dim CheckItem = cboCountry.Items.FindByText(str)
If CheckItem Is Nothing Then
End If
End If
Next ci
cboCountry.SelectedIndex = cboCountry.Items.IndexOf(cboCountry.Items.FindByText(DEFAULT_COUNTRY))
f_Value = cboCountry.SelectedValue
Return cboCountry.SelectedValue
End Function
Public Sub DefaultValue()
Me.cboCountry.SelectedValue = DEFAULT_COUNTRY
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Public Property Value() As String
Return f_Value
End Get
Set(ByVal Value As String)
f_Value = Value
cboCountry.SelectedIndex = cboCountry.Items.IndexOf(cboCountry.Items.FindByText(f_Value))
End Set
End Property
Private Sub cboCountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboCountry.SelectedIndexChanged
f_Value = cboCountry.SelectedValue
End Sub
End Class

Posts : 256
Join date : 2008-06-06

View user profile

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum