Rotator onItemDataBound always first record

3 posts, 0 answers
  1. Olivier
    Olivier avatar
    146 posts
    Member since:
    Nov 2010

    Posted 10 Mar 2015 Link to this post

    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. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 13 Mar 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tapesh
    Tapesh avatar
    1 posts
    Member since:
    Dec 2015

    Posted 05 Dec 2015 Link to this post

    Your sample helped a lot... Thank you Slav
Back to Top