473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Question about Image Column in gridview Fw2.0

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.

Feb 12 '06 #1
3 1474
<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
"Dave Bareham" wrote:
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.

Feb 13 '06 #2

"Phillip Williams" wrote:
<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
Feb 13 '06 #3
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}'/>"/>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Dave Bareham" wrote:

"Phillip Williams" wrote:
<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

Feb 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Tan | last post by:
Hi I am desperate for any help with display image in Gridview I have a gridview contain surname , forename ..... and image. I could not display image as my database store the column image as...
4
by: lanem | last post by:
I want an image and text in the column header in my GridView. Does anyone know how to do that? Thanks.
18
by: Auto | last post by:
Hello, I would like to know how do display an image into a Gridview (ASP.NET 2.0) taken directly from a DataBase, NOT using an URL, like described in this article: ...
1
by: Smokey Grindle | last post by:
does anyone know of a good example of asp.net 2.0's gridview showing a sort order arrow in the column header correctly and working? I cant seem to get what ive found on google to work (see previous...
3
by: Gunawan | last post by:
Dear All, I have data which display on the GridView. GridView contain 3 Column (ProductId, ProductCode and Description). I would like to display only Product Code and Description so I hide...
2
by: Dale | last post by:
This seems like it should be simple and I am pretty sure I've done similar things a hundred times before but I sure can't seem to get it right this time. I have a GridView with a column of text...
2
by: Beemer Biker | last post by:
I have a 10 row (per page) gridview where the first column is a small image under 100x200px and the second column is a DropDownList template that selects which image to show in the first column. ...
1
by: TimmyTurner | last post by:
Hi all, I am trying to view an image from the database in the gridview control. I set up my SQLDatasource, and when testing the query i can see the images in the preview table, then i add a...
3
by: Froefel | last post by:
Hi group, I'm looking for some help on how to achieve the following in a gridview control that is based on an ObjectDataSource. The SelectMethod of the datasource returns a list of Customer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.