Which Transfer button has been clicked

6 posts, 1 answers
  1. NMQA
    NMQA avatar
    6 posts
    Member since:
    Nov 2011

    Posted 23 Nov 2011 Link to this post

    Hi Telerik,

    This looks to be a fairly straight forward thing, be I cannot seem to detect which Arrow (To Right or To Left) have been clicked on the OnTransferred event (server-side).

    Here is some sample codes:
    <telerik:RadListBox runat="server" ID="listBoxSourceOS" Height="200px" Width="230px"                                                    OnDropped="listBoxSourceOS_OnDropped" ButtonSettings-ShowTransferAll="false"                                                    EnableDragAndDrop="true" AutoPostBackOnTransfer="true" OnTransferred="ListBoxSourceOS_OnTransferred"                                                    AllowTransfer="true" TransferToID="listBoxDestinationOS">
    </telerik:RadListBox>
     
    <telerik:RadListBox TransferToID="listBoxSourceOS" Height="200px" ID="listBoxDestinationOS" AutoPostBackOnTransfer="true" AllowTransfer="true" runat="server" Width="230px" />

    protected void ListBoxSourceOS_OnTransferred(object sender, RadListBoxTransferredEventArgs e)
            {
                //((Telerik.Web.UI.RadListBoxItem[])(e.Items))[0].Value
                if (e.Items != null)
                {
                    //Insert new item
                    //Refresh List
                }
            }


    Based on the type of transfer, a delete or insert operation will the be carried out into the database, all in the code-behind page(server side)

    Furthermore, this same scenario will be applied for the OnDropped events.

    Thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Nov 2011 Link to this post

    Hello,

    The OnTransferred event fires whenever there is a drag and drop or transfer between the ListBoxes depending on the direction of transfer.

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. NMQA
    NMQA avatar
    6 posts
    Member since:
    Nov 2011

    Posted 23 Nov 2011 Link to this post

    Hi,

    In my case, OnTransferred is being triggered regardless of which Arrow have been pressed. My understanding is to find out the type of the arrow clicked on at this point.. 

    Cheers!
  5. Answer
    Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 23 Nov 2011 Link to this post

    Hello NMQA,

    You could use this piece of code to determine if a delete or insert operation should be performed:

    protected void RadListBox1_Transferred(object sender, RadListBoxTransferredEventArgs e)
        {
            if (e.DestinationListBox != sender)
            {
                // perform delete logic
            }
            else if (e.DestinationListBox == sender)
            {
                // perform insert logic
            }
        }

    So if the DestinationListBox is not the sender, it means an item was removed from it. If the sender is the DestinationListBox, it means an item is being added to it.

    I hope that helps.
  6. NMQA
    NMQA avatar
    6 posts
    Member since:
    Nov 2011

    Posted 23 Nov 2011 Link to this post

    Thank you Sir! 

    Came up with this, which basically is the same thing that you've proposed.

    if (e.SourceListBox == listBoxSourceOS)
    {
        //Do something
    }
    else
    {
        //Do something
    }

    Nice one Kevin!
  7. Josef Rogovsky
    Josef Rogovsky avatar
    144 posts
    Member since:
    Sep 2012

    Posted 07 Aug 2015 in reply to NMQA Link to this post

    Thanks, All

    This thread was helpful.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017