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

RadListBox drag and drop position problem

3 Answers 138 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Meng
Top achievements
Rank 1
Meng asked on 14 Dec 2012, 10:58 PM
Hi there,

I am experiencing a problem when using drag and drop with Radlistboxes. 

Here is the scenario:

I drag an item from one Radlistbox and drop into the middle position of a second Radlistbox, When I iterate the items in the second Radlistbox using a foreach loop, it seems that the item I just dropped was iterated at the end of the loop. Isnt it suppose to be looped  in the middle? Any help or suggestions would be greatly appreciated.

Thanks,
Meng

3 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 17 Dec 2012, 03:40 PM
Hi Meng,

I've tested the described scenario, but the problem did not reproduce on my end. Please take a look at the attached page and see if it works accordingly on your end. Also, please specify the version of the controls you are using.
 
Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tarun
Top achievements
Rank 1
commented on 10 Jun 2023, 11:17 PM | edited

Thanks Meng.
0
Meng
Top achievements
Rank 1
answered on 17 Dec 2012, 04:32 PM

Hi Bozhidar,

Thanks for your reply. In the example you provided, the listbox was looped in the button_click event. I am experiencing this issue in the OnTransferred event of ListBox1, please see the code below. If you drag one item to the second listbox, then drag it back to the middle position of the first listbox, the item was iterated at the end of the loop. Thank you. 

<form id="form1" runat="server">
    <div>
       <asp:ScriptManager ID="ScriptManager1" runat="server">
       </asp:ScriptManager>
  
        <telerik:RadListBox 
            ID="RadListBox1" runat="server" OnTransferred="RadListBox2_Transferred" 
            AllowTransfer="true" EnableDragAndDrop="true" AutoPostBackOnTransfer="true"             
            TransferToID="RadListBox2">
              
        </telerik:RadListBox>
          
        <telerik:RadListBox ID="RadListBox2" EnableDragAndDrop="true" AutoPostBackOnTransfer="true" runat="server">
              
        </telerik:RadListBox>
  
        <asp:Label Text="" ID="Label1" runat="server" />
  
    </div>
    </form>
  
  
Code Behind:
  
protected void Page_Load(object sender, EventArgs e)
    {
         if (!this.IsPostBack)
          {
            RadListBox1.LoadContentFile("XMLFile.xml");
            RadListBox2.LoadContentFile("XMLFile.xml");
          
    }
    protected void RadListBox2_Transferred(object sender, RadListBoxTransferredEventArgs e)
    {
        try
        {
            Label1.Text = String.Empty;
            foreach (RadListBoxItem item in RadListBox1.Items)
            {
                string text = item.Text;
                Label1.Text += text + "; ";
            }
        }
        catch
        { }
    }
  
XML Data file:
  
<?xml version="1.0" encoding="utf-8" ?>
<Items>
  <Item Text="Group1" Value ="100" />
  <Item Text="Group2" Value ="200" />
  <Item Text="Group3" Value ="300" />
  <Item Text="Group4" Value ="400" />
  <Item Text="Group5" Value ="500" />
  <Item Text="Group6" Value ="600" />
  <Item Text="Group7" Value ="700" />
</Items>

 

0
Bozhidar
Telerik team
answered on 18 Dec 2012, 09:01 AM
Hello Meng,

This happens because the OnTransferred event is raised before the items are put in their respective order. This is a design decision and getting the correct order of the items in the OnTransferred event is not possible.
 
Kind regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListBox
Asked by
Meng
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Meng
Top achievements
Rank 1
Share this question
or