Hyperlink with image in datagrid

  • Thread starter Thread starter Vik
  • Start date Start date
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.
 
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
 
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
 
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,
 
Back
Top