Drag and dropped items does not show up on dynamically created listbox

2 posts, 0 answers
  1. burak
    burak avatar
    3 posts
    Member since:
    May 2009

    Posted 28 Feb 2013 Link to this post

    Hi guys,

    I'm having a problem with the drag and drop functionality of the radlistbox.

    In my scenario i need to create dynamic controls depending to the data coming from the database. When I drag and drop an item from static listbox to the listboxes dynamically created, items does not show up until some other control other than listbox forces an autopostback. I have tried setting autopostbackaftertransfer  to true but still the same result. I can see that item dropped event on the server side is triggering and all the items I previously dropped to the listbox is available within the listbox's item collection thou not visible until another control forces a postback. Any ideas what could be causing the problem?

    protected void Page_Load(object sender, EventArgs e)
            if (Page.IsPostBack)
                 //generate forms again using existing variables
                 //get some initial variables from querystring
     protected void GenerateSlotForms()
                    divSlot.Visible = true;
                    int tblRows, tblCols;
                    DataView dvCorpSlot;
                    dvCorpSlot = (DataView)CorpSlot.Select(DataSourceSelectArguments.Empty);  //corporation lists
                    if (RadNumericTextBox5.Value == 1)
                        tblRows = 1;
                        tblCols = 1;
                        tblRows = (Convert.ToInt16(dvCorpSlot.Count) / 2) + (Convert.ToInt16(dvCorpSlot.Count) % 2);
                        tblCols = 3;
                    int k = 0;
                    for (int i = 0; i < tblRows; i++)
                        TableRow tr = new TableRow();
                        for (int j = 0; j < tblCols; j++)
                            TableCell tc = new TableCell();
                            if ((i * 3) + j + 1 <= Convert.ToInt16(dvCorpSlot.Count))
         private Control CreateControlSlotListBox(int i)
                ListBox SlotListBox = new ListBox();
                SlotListBox.ID = "SlotListBox" + i;
                SlotListBox.Width = 190;
                return SlotListBox;

        protected void RadListBox_Dropped(object sender, RadListBoxDroppedEventArgs e)
                foreach (RadListBoxItem item in e.SourceDragItems)
                    string controlname = e.HtmlElementID;
                    if (controlname.Contains("Skinned")) { controlname = controlname.Substring(7); }
                    ListBox slotListBox = (ListBox)Page.FindControl(controlname);
                    slotListBox.Items.FindByText(item.Text).Value = item.Value;


    <div id="divSlot" runat="server" visible="false">

    telerik:RadListBox ID="RadListBox1" runat="server" EnableDragAndDrop="true" SelectionMode="Multiple"
    AllowTransferDuplicates="True" DataKeyField="Descr" OnDropped="RadListBox_Dropped" Height="250"
    ataSourceID="PPIEEmployeeListAll" DataTextField="Descr" DataValueField="Expr1">                  </telerik:RadListBox>

    asp:PlaceHolder ID="PlaceHolder1" runat="server" EnableViewState="false"></asp:PlaceHolder>

  2. Nencho
    Nencho avatar
    1458 posts

    Posted 05 Mar 2013 Link to this post

    Hello Burak,

    Could you elaborate a bit more on the scenario you attempt to achieve. How do you associate the newly created control with the ListBox you need to allow transferring? In addition, please keep in mind that Dropped event will not be fired, when you drop an item over another RadListBox/RadListBoxItem.

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top