Unplanned
Last Updated: 17 Apr 2024 14:43 by ADMIN
Michael
Created on: 15 Jun 2020 08:20
Category: DropDownList
Type: Bug Report
0
RadDropDownList: exception when trying to change the selected item in SelectedValueChanged event
When I select items 1 through 4 in the drop-down list, the expected event occurs (the selected item is removed from the drop-down list and added to the list view).  When I select the last item in the list (item 5), the item is added to the list and then I get the ArgumentOutOfRangeException. 
Attached Files:
1 comment
ADMIN
Nadya | Tech Support Engineer
Posted on: 15 Jun 2020 09:31

Hello Michael,

To workaround this you can use the SelectedIndexChanging event:

private void radDropDownList1_SelectedIndexChanging(object sender, Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
{
    try
    {
        e.Cancel = true;

        ListItem selectedItem = (ListItem)radDropDownList1.Items[e.Position].DataBoundItem;

        if (selectedItem == null || selectedItem.ID == 0)
            return;

        lvListItems.Add(selectedItem);
        cbListItems.Remove(selectedItem);

    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

I hope this helps.

Regards,
Nadya
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.