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

SourceDragItems empty when dragging dynamically created items

0 Answers 25 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 14 Jan 2011, 08:22 PM
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.

No answers yet. Maybe you can help?

Tags
ListBox
Asked by
Sean
Top achievements
Rank 2
Share this question
or