SourceDragItems empty when dragging dynamically created items

1 posts, 0 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 14 Jan 2011 Link to this post

    Hi all,

    If I have a static item such as:

    <Items>
    <telerik:RadListBoxItem Text="Test" />
    </Items>

    I see this item in e.SourceDragItems when this function is called:

    protected void RadListBox_Dropped(object sender, RadListBoxDroppedEventArgs e)
    {
        foreach( RadListBoxItem item in e.SourceDragItems)
        {
            RadDock dock = CreateRadDock();
            dock.Tag = item.Text;
            dock.Title = dock.Tag + CurrentDockStates.Count.ToString();
            LoadContent(dock);
            RadDockZone1.Controls.Add(dock);
        }
    }

    But, if I add an item to the ListBox at run time:

    protected void LoadHistoricalReports( ReportServicesProxy.HistoricalReport[] historicalReports )
    {
        RadListBox2.Items.Clear();
     
        foreach( var report in historicalReports )
        {
            RadListBoxItem currentItem = new RadListBoxItem(report.Name);
            RadListBox2.Items.Add(currentItem);
        }
    }

    I see currentItem in my RadListBox, but when I drag the item it says that SourceDragItems is 0. How can I fix this?

    Sean

    EDIT: It seems if I add to the list box during Page_Init then they show up.
Back to Top