SourceDragItems empty when Listbox dynamically binded.

2 posts, 0 answers
  1. Steve
    Steve avatar
    1 posts
    Member since:
    Aug 2011

    Posted 09 Aug 2011 Link to this post

    Hi Telerik Team,

    I use this link and found that this is a very good example of showing something into my product.

    I open the code and implement the things as discussed in this particular page and found the things proper.

    Now the problem is this that I bind the ListBox with the database and try to drag the listbox item from there into the textbox. but now it is giving me that in the function RadListBox_Dropped, e.SourceDragItems.Count become 0 every time.

    I am writing my code here.

    protected void RadListBox_Dropped(object sender, RadListBoxDroppedEventArgs e)
            if (txtNoteArea.ClientID == e.HtmlElementID)
                txtNoteArea.Text = String.Empty;
                foreach (RadListBoxItem item in e.SourceDragItems)
                    txtNoteArea.Text += item.Text + ", \n";
                if (txtNoteArea.Text.Length > 0)
                    txtNoteArea.Text = txtNoteArea.Text.TrimEnd(new char[] { ',', ' ', '\n' });
        public void BindStandardNotes()
            DataSet dsMC = new DataSet();
            SqlConnection con = new SqlConnection(System.Web.Configuration.WebConfigurationManager.AppSettings["con"]);
            SqlDataAdapter adp = new SqlDataAdapter("SPNAME", con);
            adp.SelectCommand.CommandType = CommandType.StoredProcedure;
            lstStandardNotes.DataSource = dsMC;
            lstStandardNotes.DataValueField = "ID";
            lstStandardNotes.DataTextField = "TEXT";

    <telerik:RadListBox ID="lstStandardNotes" runat="server" Width="90%" Height="200px" SelectionMode="Multiple"
                                                                            AutoPostBackOnReorder="false" EnableDragAndDrop="true" OnDropped="RadListBox_Dropped" />
    <asp:TextBox ID="txtNoteArea" runat="server" Wrap="true" Rows="8" TextMode="MultiLine" Width="90%" Height="200px" ValidationGroup="QAN" />

    This code is working fine if I put some static items into the ListBox, but when I bind with the Database, the SourceDragItem count become 0.

    Please assist me ASAP.

    Steve Austin
  2. Peter Filipov
    Peter Filipov avatar
    1028 posts

    Posted 12 Aug 2011 Link to this post

    Hello Steve,

    I'm sending you a sample project that implements your scenario.

    Peter Filipov
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top