This is a migrated thread and some comments may be shown as answers.

Radlistbox items inserted when allow duplicates set to False

1 Answer 159 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Ingrid Williams
Top achievements
Rank 1
Ingrid Williams asked on 28 Jul 2011, 02:38 PM
I am trying to display the items inserted into the destination listbox when multiple items are selected from the source but the items inserted is only the ones that are not duplicates since allow dupliates is set to false.  Below is my code.  However,  I am getting the items selected.  How do I get only the items that were actully inserted since it is not adding the duplicates.

Protected

Sub rlDestinationGroup_Inserted(sender As Object, e As Telerik.Web.UI.RadListBoxEventArgs) Handles rlDestinationGroup.Inserted

  'gets the selected employee name

  Dim empName As String = rdCBEmpList.SelectedItem.Text

   lblMsg.Text = empName & " was added to the following group(s): "

 ' returns the list of items selected from the Source List

  For Each item As RadListBoxItem In rlGroupListSource.SelectedItems

 lblMsg.Visible = True

 lblMsg.Text += item.Text & ", "

 Next

 End Sub

Your assistance is appreciated.

 

1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 03 Aug 2011, 12:09 PM
Hello Ingrid Williams,

I suggest that you hook to the Trasnferring event and use the following code there:

Private Sub ListBox1_Transferring(sender As Object, e As RadListBoxTransferringEventArgs)
    Dim resultItems = e.Items.Where(Function(item) e.DestinationListBox.FindItemByText(item.Text) Is Nothing)
End Sub

the resultItems are the items which will be actually inserted (no duplicates).

Kind regards,
Genady Sergeev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ListBox
Asked by
Ingrid Williams
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or