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

SourceDragItems empty when Listbox dynamically binded.

1 Answer 36 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 09 Aug 2011, 09:41 AM
Hi Telerik Team,

I use this link and found that this is a very good example of showing something into my product.
http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/draganddrop/defaultcs.aspx

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;
        adp.Fill(dsMC);
        lstStandardNotes.DataSource = dsMC;
        lstStandardNotes.DataValueField = "ID";
        lstStandardNotes.DataTextField = "TEXT";
        lstStandardNotes.DataBind();
    }

<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.

Regards,
Steve Austin

1 Answer, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 12 Aug 2011, 09:09 AM
Hello Steve,

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

Greetings,
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.

Tags
PanelBar
Asked by
Steve
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Share this question
or