With Standard comboboxes, I would set up a Key and Value. When I try the same with the RadDropdownlist, I get an error, when I try to get the value for the SelectedItem.Key.
The following code block is how I populate the RadDropdownlist. This works just fine. Notice line 10 and 11 where I set the members as Key and Value
01.
''' <summary>
02.
''' Populates the dropdown_ cust serv cntry.
03.
''' </summary>
04.
Private
Sub
PopulateDropdown_CustServCntry()
05.
06.
cboCustServ_Cntry.Items.Clear()
07.
08.
Try
09.
cboCustServ_Cntry.DataSource =
New
BindingSource(dictCntry,
Nothing
)
10.
cboCustServ_Cntry.DisplayMember =
"Value"
11.
cboCustServ_Cntry.ValueMember =
"Key"
12.
13.
'Default to US
14.
cboCustServ_Cntry.SelectedIndex = cboCustServ_Cntry.FindString(
"UNITED STATES"
)
'United States code
15.
16.
Catch
ex
As
Exception
17.
End
Try
18.
End
Sub
'PopulateDropdown_CustServCntry
When I enter the following code for the SelectedIndexChanged event, I get the error at line 07. Is there a way I can make this work with the radDropdownlist?
01.
Private
Sub
cboCustServ_Cntry_SelectedIndexChanged(sender
As
Object
, e
As
Telerik.WinControls.UI.Data.PositionChangedEventArgs)
Handles
cboCustServ_Cntry.SelectedIndexChanged
02.
'need to set up State dropdown based on selected country
03.
Dim
CntryCode
As
String
=
""
04.
05.
Try
06.
Try
07.
CntryCode = cboCustServ_Cntry.SelectedItem.Key
08.
Catch
ex
As
InvalidCastException
09.
10.
End
Try
11.
12.
13.
If
Not
IsNothing(CntryCode)
AndAlso
CntryCode.Trim <>
""
Then
14.
PopulateDropdown_CustServState(CntryCode)
15.
cboCustServ_State.SelectedIndex = -1
16.
End
If
17.
18.
Catch
ex
As
Exception
19.
20.
End
Try
21.
End
Sub
'cboCustServ_Cntry_SelectedIndexChanged
I appreciate your input!