Default Image for GridImageColumn

3 posts, 0 answers
  1. Matt
    Matt avatar
    13 posts
    Member since:
    Aug 2015

    Posted 23 Aug Link to this post

    I have a RadGrid up and running, and have added GridImageColumn. It works well. However, not all rows have an associated image. How would I setup a default image that would display in those instances? 

     

    <telerik:GridImageColumn DataType="System.String" DataImageUrlFields="PartFamily"
      DataImageUrlFormatString="images/family-images/{0}.png" AlternateText="Family Image" DataAlternateTextField="PartFamily"
      ImageAlign="Middle" ImageHeight="75px" ImageWidth="75px"  HeaderText="Image Column"
      
    </telerik:GridImageColumn>

  2. Roberto
    Roberto avatar
    13 posts
    Member since:
    Mar 2011

    Posted 23 Aug in reply to Matt Link to this post

    Change the PartFamily Field in your Query to set the default image.

    Ex: 

    Case When PartFamily <>'' Then PartFamily Else 'DefaultImage.jpg' End as PartFamily

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matt
    Matt avatar
    13 posts
    Member since:
    Aug 2015

    Posted 23 Aug in reply to Roberto Link to this post

    Unfortunately, the DB does not know whether or not the image actually exists. It just spits out "PartFamily" and assumes there is a matching PNG file to go with it. 

     

Back to Top