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. Try09. cboCustServ_Cntry.DataSource = New BindingSource(dictCntry, Nothing)10. cboCustServ_Cntry.DisplayMember = "Value"11. cboCustServ_Cntry.ValueMember = "Key"12. 13. 'Default to US14. cboCustServ_Cntry.SelectedIndex = cboCustServ_Cntry.FindString("UNITED STATES") 'United States code15. 16. Catch ex As Exception17. End Try18.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.SelectedIndexChanged02. 'need to set up State dropdown based on selected country03. Dim CntryCode As String = ""04. 05. Try06. Try07. CntryCode = cboCustServ_Cntry.SelectedItem.Key08. Catch ex As InvalidCastException09. 10. End Try11. 12. 13. If Not IsNothing(CntryCode) AndAlso CntryCode.Trim <> "" Then14. PopulateDropdown_CustServState(CntryCode)15. cboCustServ_State.SelectedIndex = -116. End If17. 18. Catch ex As Exception19. 20. End Try21.End Sub 'cboCustServ_Cntry_SelectedIndexChanged
I appreciate your input!
