Question about Image Column in gridview Fw2.0

G

Guest

I'm fairly new to this so bear with me!

I have created a gridview in an aspx page which successfully talks to a SQL
backend via a datasource. One of the colums contains a reference to an image
which I display as a column in the grid. This works.

My question is this. Can I make the image into a hyperlink so that when I
click on the image it effectively causes a hyperlink equivalent to the
example below.

TIA

Dave

<A href=""anotherpage.aspx?ID=n"><img etc...></a>

Where n=the identity value of the ID column.
 
G

Guest

<asp:HyperLinkField DataNavigateUrlFields="ID_FieldName"
DataNavigateUrlFormatString="anotherpage.aspx?id={0}"
Text ="<img src='MyImage.gif'/>" />
 
G

Guest

Phillip Williams said:
<asp:HyperLinkField DataNavigateUrlFields="ID_FieldName"
DataNavigateUrlFormatString="anotherpage.aspx?id={0}"
Text ="<img src='MyImage.gif'/>" />

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

Thanks Philip, that kind of helped but the actual file name of the img is
variable and is held in one of the fields in the row.

For example, the source may contain the following fields

ID int identity etc,
Text Field varchar(50),
ImgName varchar(50) , /*E.g.,'iconname.gif' */
OtherFields

How can I make gridview column use the ImgName as the source file name for
the image?

TIA,

Dave
 
G

Guest

Hi Dave,

You can use the DataTextField property to get the image name from the data
like this:

<asp:HyperLinkField DataNavigateUrlFields="ID_FieldName"
DataNavigateUrlFormatString="anotherpage.aspx?id={0}"
DataTextField="ImgName" DataTextFieldFormatString="<img src='{0}'/>"/>
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top