Click here to Skip to main content
13,349,033 members (70,181 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


10 bookmarked
Posted 18 Jan 2011

Display image in asp:HyperLinkField of GridView

, 19 Jan 2011
Rate this:
Please Sign up or sign in to vote.
Shows how to display an image (instead of simple text) in asp:HyperLinkField or asp:LinkButton column of a GridView
By default, asp:LinkButton and asp:HyperLinkField, being used for GridView navigation, shows simple text hyperlinks. You can easily place an image as a hyperlink. Follow this trick in order to display an image (instead of simple text) in asp:HyperLinkField or asp:LinkButton column.
Here is the code for the asp:HyperLinkField to display image:
<asp:HyperLinkField Text="&lt;img src='Images/img.png' alt='alternate text' border='0'/&gt;">

In the Text property, the less than sign (<) and the greater than sign (>) should be replaced with their Character Entities.
And to show image in asp:LinkButton, use the following code:
<asp:LinkButton runat="server" Text="&lt;img src='/Images/img_btn.png' alt='Button' border='0'/&gt;">


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Awais Hafeez 86
Pakistan Pakistan
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionExcelent Pin
necoide4-Apr-13 10:00
membernecoide4-Apr-13 10:00 
Thanks. I can't add a templatefield in my gridview because it is using EnableSortingAndPagingCallbacks. This solution helped me a lot. Big Grin | :-D
GeneralMy vote of 5 Pin
Member 977903925-Feb-13 0:12
memberMember 977903925-Feb-13 0:12 
QuestionGreat Tip! Pin
Alman6611-Oct-12 3:26
memberAlman6611-Oct-12 3:26 
GeneralReason for my vote of 3 Why do someone use this complex meth... Pin
Venkatesh Mookkan19-Jan-11 20:18
memberVenkatesh Mookkan19-Jan-11 20:18 
GeneralWhy do someone use this complex method even though we can si... Pin
Venkatesh Mookkan19-Jan-11 20:17
memberVenkatesh Mookkan19-Jan-11 20:17 
GeneralFixed HTML encoding Pin
Indivara19-Jan-11 19:28
subeditorIndivara19-Jan-11 19:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 20 Jan 2011
Article Copyright 2011 by Awais Hafeez 86
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid