+1-888-365-2779
Try Now
More in this section

Forums / Ecommerce / Images not shown in custom widget

Images not shown in custom widget

6 posts, 0 answered
  1. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    23 Aug 2011
    Link to this post
    I created an image slider (jquery) which should slide through my product images. I use the following code:

    protected void Page_Load(object sender, EventArgs e) {
     
                if (!IsPostBack) {
                    rptProductSlider.ItemDataBound += new RepeaterItemEventHandler(rptProductSlider_ItemDataBound);
                    BindData();
                }
            }
     
            void rptProductSlider_ItemDataBound(object sender, RepeaterItemEventArgs e) {
     
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
     
                    Product p = e.Item.DataItem as Product;
                     
                    var imgProduct = e.Item.FindControl("imgProduct") as Image;
                    imgProduct.ImageUrl = p.ThumbnailUrl;
                    imgProduct.AlternateText = p.ThumbnailAlternativeText;
                }
            }
     
            private void BindData() {
                 
                var manager = CatalogManager.GetManager();
                this.rptProductSlider.DataSource = manager.GetProducts();
                this.rptProductSlider.DataBind();
            }

    For some reason the slider shows the default image instead of the image that I uploaded with my products.
    /SFRes/images/Telerik.Sitefinity.Resources/Images.DefaultProductTmb.png

    What am I doing wrong? The ProductList control that comes with the ECommerce module, is showing the images without a problem?

    Regards,
    Daniel
  2. Tom
    Tom avatar
    5 posts
    Registered:
    23 Aug 2011
    23 Aug 2011
    Link to this post
    Hi Daniel,

    You'll need to call CatalogManager's "PopulateImages" function on the list of Products that are returned from "GetProducts". Alternatively, you can call "SetProductImages" on each Product returned from "GetProducts".

    Regards,
    Tom
  3. Daniel Plomp
    Daniel Plomp avatar
    952 posts
    Registered:
    18 Feb 2004
    25 Aug 2011
    Link to this post
    Can't figure out what 'provider' I have to fill in with this method. The SetProductImages() works okay, though...
  4. Tom
    Tom avatar
    5 posts
    Registered:
    23 Aug 2011
    25 Aug 2011
    Link to this post
    Passing an empty string for that parameter will be fine in most cases.
  5. Daniel Plomp
    Daniel Plomp avatar
    112 posts
    Registered:
    14 Jun 2012
    29 Aug 2011
    Link to this post
    Hm... doesn't work, unfortunately.
  6. Venkata Koppaka
    Venkata Koppaka avatar
    67 posts
    Registered:
    24 Sep 2012
    31 Aug 2011
    Link to this post
    Hi Daniel Plomp,

    The solution that Daniel suggested will work. I am also providing you a small sample attached to this reply where I demonstrated how you would get list of Products with Images.

    Let me know if you are still facing any issues, and I will be glad to help.

    Kind regards,
    Venkata Koppaka
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

6 posts, 0 answered