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

GridHyperLinkColumn with dynamic image

2 Answers 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Najid Hanif
Top achievements
Rank 2
Najid Hanif asked on 02 May 2012, 03:31 PM
I have a simple grid and I want to have links to files and just show an image based on their file extension. The code below gets me close but the image is static.
<telerik:GridHyperLinkColumn AllowFiltering="False" DataNavigateUrlFields="Application_Key, File_Title, File_Name, FileExt" DataNavigateUrlFormatString="att/{0}/{2}" DataTextField="File_Title" ImageUrl="img/doc.png" ShowSortIcon="False" Target="_blank" UniqueName="FileCol">
</telerik:GridHyperLinkColumn>

The GridImageColumn has a property that would work perfectly DataImageUrlFormatString="IMG/{0}.png" but it does not have DataNavigateUrlFormatString  :(

How can I do this?

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Richard
Top achievements
Rank 1
answered on 03 May 2012, 09:54 PM
Najid:

I think the best solution for your requirement would be to stick with the GridHyperlinkColumn and simply use conditional logic in your code behind to assign the imageurl, based on a check of the file type.

I would suggest that you reference this forum thread for a starting point, as it shows how to assign the ImageURL property using the RadGrid_ItemDataBound event (both in C# and VB).

Image replacement for GridHyperLinkColumn

I hope this helps!
0
Najid Hanif
Top achievements
Rank 2
answered on 07 May 2012, 12:49 AM
Thanks, that got me going.
Tags
Grid
Asked by
Najid Hanif
Top achievements
Rank 2
Answers by
Richard
Top achievements
Rank 1
Najid Hanif
Top achievements
Rank 2
Share this question
or