Hyperlink with image in datagrid

V

Vik

I need to put an image with a hyperlink into a datagrid's column. A file
name for the image's source and a parameter for the hyperlink should come
from another datagrid's column. How can I do this?

Thank you.
 
A

Andrea Zani

I need to put an image with a hyperlink into a datagrid's column. A file
name for the image's source and a parameter for the hyperlink should come
from another datagrid's column. How can I do this?

Thank you.

With TemplateColumn:

<asp:templateColumn>
<itemtemplate>
<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl="yourpage.aspx">
<img src='<%# DataBinder.Eval(Container.DataItem,"column") %>'
/></asp:HyperLink>
</itemtemplate>
</asp:templateColumn>

Bye
 
J

Joel Palmer

I had a similar problem. I ended up having to do it in the stored procedure.
Someting like this...

SP:

select '<a href='+Url+'><img src='+ImgSrc+'></a>' as ImageLink
....
from yourtable


ASP:

<Columns>


<asp:BoundColumn DataField="ImageLink"
HeaderText="Whatever you want" />

I am sure there is a better way.

JOEL
 
N

Noel Hoo

Hi Vik,

You'll have to use a templated column and then user the
DataBinder.Eval(....) to construct the appropriate html tags...

Hope this helps. (If not drop me an email, and I'll help you through it)

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top