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

Rotator onItemDataBound always first record

2 Answers 31 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Olivier
Top achievements
Rank 2
Olivier asked on 10 Mar 2015, 11:43 AM
Hello

i have a problem and i don't find any solution,

In page load i use it :
if (!Page.IsPostBack) {
            List<affaires> oAff = this.DbContext.Bien_GetPhoto<affaires>("B12546" ,2).ToList();
            this.RadRotator1.DataSource = oAff;
            this.RadRotator1.DataBind();
}

and on itemDatabound

protected void RadRotator_ItemDataBound(object sender, RadRotatorEventArgs  e) {
           affaires oBoPhoto = (affaires)e.Item.DataItem;
            
           string cPhoto = "photo/" + oBoPhoto.photo.Trim().ToString().Replace("\\", "/");
           if (File.Exists(Server.MapPath(cPhoto))) {
               ((Image)e.Item.FindControl("photo_mini")).ImageUrl      = cPhoto;
               ((TextBox)e.Item.FindControl("txt_img")).Text = cPhoto;
           } else {
               ((Image)e.Item.FindControl("photo_mini")).ImageUrl      ="~/images/photoempty_v.jpg";
               ((TextBox)e.Item.FindControl("txt_img")).Text = cPhoto;
           }
            
       }


And i get always First Record, the count is ok, but the picture is always the same !


thanks
Olivier

2 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 13 Mar 2015, 08:30 AM
Hello Olivier,

Your approach appears to be correct and it works on my end as you can check in the attached sample page. Most probably the problem at hand stems from the data that is loaded in the RadRotator control.

You mentioned that the same picture is loaded in all items of the rotator. Is it a picture from the data source or is it photoempty_v.jpg? In case the photoempty_v.jpg file is loaded, most probably the path you pass to the MapPath method is not a valid one.

If the image that is loaded in the rotator is from the data source, please check the data source and verify that it indeed contains different image file names and not the same one in all records.

If you are still having difficulties after checking the information above, try reproducing the problem you encountered in the attached sample page and send it so that I can inspect it locally and provide a more to the point answer.

Regards,
Slav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Tapesh
Top achievements
Rank 1
answered on 05 Dec 2015, 06:12 AM
Your sample helped a lot... Thank you Slav
Tags
Rotator
Asked by
Olivier
Top achievements
Rank 2
Answers by
Slav
Telerik team
Tapesh
Top achievements
Rank 1
Share this question
or