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

Binding RadListBoxItem

1 Answer 130 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 18 Jan 2010, 09:49 PM
Hi all,

  I am trying to do a drag and drop shopping cart very similiar to the  http://demos.telerik.com/aspnet-ajax/listbox/examples/functionality/templates/defaultcs.aspx.  I am using Item Templates with a style override of list tag to display inline creating a horizatal layout of products.  




  Currently I am pulling my data of products in using LingtoSql then binding the data with this:
 var db = new Products.ProductsDataContext();  
        var floorthumbs = (from c in db.Floorings  
                           select c);  
 
        RadListBox1.DataSource = skus;  
        RadListBox1.DataBind(); 

  I  tried using <img class="product-image" src='Images/<%# DataBinder.Eval(Container, "Value")%>' /> to bind the image tag.  I ended up dropping DataBinder.Eval to use just Eval to get image to display.

When I attempt to transfer an item from the Product list to the Detail View & Purchase, the RadListBox2 does not bind the image name. 

What is the best method to duplicate the example with pulling in live data from a database?
Is it possible to load to the RadListBoxItem dynamiclly in the code behind?

Thanks,
David

1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 19 Jan 2010, 06:14 PM
Hi David ,

You need to call the DataBind method of the destination listbox whenever an item is transferred. I suggest that you hook on the OnTransferred server side event and call the destination listbox databind method there. Example code:

protected void Page_Load(object sender, EventArgs e)
   {
       RadListBox1.DataBind();
       RadListBox1.Transferred += new RadListBoxTransferredEventHandler(RadListBox1_Transferred);
   }
 
   void RadListBox1_Transferred(object sender, RadListBoxTransferredEventArgs e)
   {
       e.DestinationListBox.DataBind();
   }


Sincerely yours,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ListBox
Asked by
David
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or