Use an Image in a HyperLinkColumn

I’ve seen a lot of posts on boards of people inquiring how to utilize an image in a hyperlinkcolumn.  I found those posts, because I was trying to do the same thing.  In my codebehind, I had some custom things going on for the link, and really didn’t feel like comprimising any of that by calling DataBinder.Eval in an item template column.  So if you just need an image in a hyperlinkcolumn, here’s an easy solution.

All you have to do is reference your image in the text value of the column, and it will render appropriately.

<asp:hyperlinkcolumn text="<img align='absmiddle' alt='View' border='0' src='images/icon_view.gif'>"></asp:hyperlinkcolumn>

Comments (0)

Skip to main content