A better way to avoid errors when setting the selected item of a drop down list which avoids using a Try and Catch statment is to change:
Try
Me.ddlCountry.Items.FindByValue(Profile.Customer.CountryID).Selected = True
Catch ex As Exception
' Select the default country
Me.ddlCountry.Items(1).Selected = True
End Try
To this:
Dim ddlItem As ListItem
ddlItem = ddlCountry.Items.FindByValue(Profile.Customer.CountryID)
If Not ddlItem Is Nothing Then
ddlItem.Selected = True
Else
' Set a default
End If
Thanks to Eric Wise for that! :0)