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

Default Image for GridImageColumn

2 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 23 Aug 2016, 04:29 PM

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 Answers, 1 is accepted

Sort by
0
Roberto
Top achievements
Rank 1
answered on 23 Aug 2016, 06:04 PM

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

Ex: 

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

0
Matt
Top achievements
Rank 1
answered on 23 Aug 2016, 06:13 PM

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. 

 

Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Roberto
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Share this question
or