Trying to capture when an item is transfered from list A to list B

2 posts, 0 answers
  1. Shannon
    Shannon avatar
    6 posts
    Member since:
    Sep 2013

    Posted 14 Sep 2015 Link to this post

    Hello,

    I am trying to capture when an item is transferred from the list RadListBoxSource to the listbox lbSupervisors.  I have put breakpoints on lbSupervisors_Inserted, lbSupervisors_Inserting, lbSupervisors_Transfered, lbSupervisors_Transfering and none of them are being hit when I transfer an item from RadListBoxSource to lbSupervisors.  Please tell me why these breakpoints are not being hit.

     

    Thanks,

    Stephen

    <%@ Page Title="" Language="C#" MasterPageFile="~/ARF.Master" AutoEventWireup="true" CodeBehind="Supervisors.aspx.cs" Inherits="ARF.Supervisors" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="cphNameDivision" runat="server">
    </asp:Content>
    <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <div class="well-large whitebg featurett one-edge-shadow minheight">
            <h3>Divisions & Supervisors</h3>
            <hr />
            <asp:Panel ID="pnlDivision" Style="float:left" runat="server" Visible="true">
                <asp:Label ID="labelDivision" runat="server" Font-Bold="true" Text="Division:"></asp:Label>
                <br />
                <telerik:RadListBox ID="lbDivisions" runat="server" Height="200px" Width="230px"
                    AutoPostBack="true" DataSourceID="DataSourceDivisions" DataValueField="ID"
                    DataTextField="Name" onselectedindexchanged="lbDivisions_SelectedIndexChanged">
                </telerik:RadListBox>
            </asp:Panel>
            <asp:Panel ID="pnlTurnpike" Style="float:left;" runat="server" Visible="false">                                                                                                         
                <asp:Label ID="lblTurnpike" runat="server" Font-Bold="true" Text="Turnpike:"></asp:Label>
                <br />
                <telerik:RadListBox runat="server" ID="lbTurnpikes" Height="200px" Width="230px"
                    AutoPostBack="true" DataKeyField="TurnpikeID"
                    DataValueField="TurnpikeID" DataTextField="TurnpikeName" Visible="true" OnSelectedIndexChanged="lbTurnpikes_SelectedIndexChanged">
                </telerik:RadListBox>
            </asp:Panel>
            <asp:Panel ID="pnlLocation" Style="float:left;" runat="server" Visible="false">
                <asp:Label ID="lblLocation" runat="server" Font-Bold="true" Text="Location:"></asp:Label>                                   
                <br />
                <telerik:RadListBox runat="server" ID="lbLocations" Height="200px" Width="230px"
                    AutoPostBack="true" DataKeyField="LocationID"
                    DataValueField="LocationID" DataTextField="LocationCodeDescription" OnSelectedIndexChanged="lbLocation_SelectedIndexChanged" Visible="true">
                </telerik:RadListBox>                     
            </asp:Panel>
            <asp:Panel ID="pnlSupervisors" Style="float:left;" runat="server" Visible="false">
                <div style="float:left;">
                    <asp:Label ID="Label1" runat="server" Font-Bold="true" Text="All Supervisors:"></asp:Label>                                   
                    <br />
                    <telerik:RadListBox runat="server" ID="RadListBoxSource" Height="200px" Width="230px" AutoPostBack="true"
                        AllowTransfer="true" TransferToID="lbSupervisors" ButtonSettings-AreaWidth="35px">
                    </telerik:RadListBox>
                </div>
                <div style="float:left;">
                    <asp:Label ID="lblSupervisors" runat="server" Font-Bold="true" Text="Current Supervisors:"></asp:Label>                                   
                    <br />
                    <telerik:RadListBox runat="server" ID="lbSupervisors" Height="200px" Width="230px" OnInserted="lbSupervisors_Inserted" OnInserting="lbSupervisors_Inserting" OnTransferred="lbSupervisors_Transfered" OnTransferring="lbSupervisors_Transfering"
                        AutoPostBack="true" DataKeyField="SupervisorID" AllowDelete="true"
                        DataValueField="SupervisorID" DataTextField="Name" Visible="true">
                    </telerik:RadListBox>                     
                </div>
            </asp:Panel>
            <asp:SqlDataSource runat="server" ID="DataSourceDivisions" ConnectionString="<%$ ConnectionStrings:ARF %>"
                SelectCommand="usp_Get_All_Divisions">
            </asp:SqlDataSource>       
        </div>
    </asp:Content>

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    namespace ARF
    {
        public partial class Supervisors : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    PopulateSupervisorsFull();
                }
            }
     
            private void PopulateTurnpikes()
            {
                lbTurnpikes.DataSource = Turnpike.GetDivisionTurnpikes(Convert.ToInt32(lbDivisions.SelectedValue), Turnpike.GetTurnpikes());
                lbTurnpikes.DataValueField = "TurnpikeID";
                lbTurnpikes.DataTextField = "TurnpikeName";
                lbTurnpikes.DataBind();
            }
     
            protected void lbTurnpikes_SelectedIndexChanged(object sender, EventArgs e)
            {
                DoTurnpikeSelectedIndexChanged(sender, e);
                if (lbTurnpikes.SelectedItem.Text == "HQ")
                {
                    PopulateSupervisors(Convert.ToInt32(lbTurnpikes.SelectedValue));
                }
                else
                {
                    ResetSupervisor();
                }
            }
     
            protected void lbLocation_SelectedIndexChanged(object sender, EventArgs e)
            {
                PopulateSupervisors(Convert.ToInt32(lbTurnpikes.SelectedItem.Value));
                lbLocations.Focus();
            }
     
            private void ResetSupervisor()
            {
                ((Telerik.Web.UI.RadListBox)(lbSupervisors)).Items.Clear();
            }
     
            private void ResetLocation()
            {
                ((Telerik.Web.UI.RadListBox)(lbLocations)).Items.Clear();
            }
     
            private void ResetDivision()
            {
                ((Telerik.Web.UI.RadListBox)(lbTurnpikes)).Items.Clear();
                ResetLocation();
            }
     
            protected void lbDivisions_SelectedIndexChanged(object sender, EventArgs e)
            {
                //Clear the division list
                ResetDivision();
                //Clear the supervisor list
                ResetSupervisor();
                 
                PopulateTurnpikes();
                //show the appropriate panels
                 
                switch (lbDivisions.SelectedItem.Text.ToString().Trim())
                {
                    case "Toll":
                        pnlLocation.Visible = true;
                        pnlTurnpike.Visible = true;
                        PopulateTurnpikes();
                        lbDivisions.Focus();
                        DoTurnpikeSelectedIndexChanged(sender, e);
                        break;
                    case "Maintenance":
                        pnlLocation.Visible = true;
                        pnlTurnpike.Visible = true;
                        lblLocation.Text = "Location:";
                        lbDivisions.Focus();
                        DoTurnpikeSelectedIndexChanged(sender, e);
                        break;
                    case "Pikepass":
                        pnlLocation.Visible = true;
                        pnlTurnpike.Visible = false;
                        lbTurnpikes.SelectedIndex = 0;
                        DoTurnpikeSelectedIndexChanged(sender, e);
                        lblLocation.Text = "Department:";
                        lbDivisions.Focus();
                        break;
                    default:
                        PopulateSupervisors(-1);
                        pnlSupervisors.Visible = true;
                        pnlDivision.Visible = true;
                        pnlTurnpike.Visible = false;
                        pnlLocation.Visible = false;
                        lbDivisions.Focus();
                        break;
                }
            }
     
            protected void DoTurnpikeSelectedIndexChanged(object sender, EventArgs e)
            {
                if (lbTurnpikes.SelectedItem != null)
                {
                    if (lbTurnpikes.SelectedItem.Text != "HQ")
                    {
                        List<Location> lstAllLocations = Location.GetLocations();
     
                        // Clear Location when Turnpike is selected or changed
                        lbLocations.Items.Clear();
     
                        switch (lbDivisions.SelectedItem.Text.ToString().Trim())
                        {
                            case "Toll":
                            case "Maintenance":
                            case "Pikepass":
                                pnlLocation.Visible = true;
                                lbLocations.DataSource = Location.GetTurnpikeLocations(Convert.ToInt16(lbDivisions.SelectedItem.Value), Convert.ToInt16(lbTurnpikes.SelectedItem.Value), lstAllLocations);
                                lbLocations.DataValueField = "LocationID";
                                lbLocations.DataTextField = "LocationCodeDescription";
                                lbLocations.DataBind();
                                lbTurnpikes.Focus();
                                break;
                            default:
                                lbLocations.DataSource = null;
                                break;
                        }
     
                    }
                    else
                    {
                        pnlLocation.Visible = false;
                        lbTurnpikes.Focus();
                    }
                }
     
            }
     
            private void PopulateSupervisors(int TurnpikeID)
            {
                List<Supervisor> lst = Supervisor.GetSupervisorsWithoutSelect();
                lbSupervisors.DataSource = Supervisor.GetDivisionTurnpikeSupervisorList(Convert.ToInt32(lbDivisions.SelectedItem.Value), TurnpikeID, lst);
                lbSupervisors.DataValueField = "SupervisorID";
                lbSupervisors.DataTextField = "Name";
                lbSupervisors.DataBind();
            }
     
            private void PopulateSupervisorsFull()
            {
                RadListBoxSource.DataSource = Supervisor.GetSupervisorsWithoutSelect();
                RadListBoxSource.DataValueField = "SupervisorID";
                RadListBoxSource.DataTextField = "Name";
                RadListBoxSource.DataBind();
            }
     
            protected void lbSupervisors_Inserted(object sender, RadListBoxEventArgs e)
            {
                foreach (RadListBoxItem item in e.Items)
                {
                    long supervisorID = Convert.ToInt32(item.ID);
                }
            }
     
            protected void lbSupervisors_Inserting(object sender, RadListBoxInsertingEventArgs e)
            {
     
            }
     
            protected void lbSupervisors_Transfered(object sender, RadListBoxTransferredEventArgs e)
            {
     
            }
     
            protected void lbSupervisors_Transfering(object sender, RadListBoxTransferringEventArgs e)
            {
     
            }
        }
    }

  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 17 Sep 2015 Link to this post

    Hello Shannon,

    First of all, in order to be able to handle the transferring operation of items at server-side you need to set the AutoPostBackOnTransfer property of the Source ListBox to true.

    Also, the responsible control that handles the process for such operations is the Source ListBox - the one that has specified the TransferToID property in its implementation. However, as I can see you have handled this events for the destination ListBox (Supervisors).

    Please consider subscribing for the OnTransferred event of the RadListBoxSource, instead of the Supervisors ListBox along with setting the AutoPostBackOnTransfer  to true.

    Regards,
    Nencho
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top