473,394 Members | 1,867 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,394 software developers and data experts.

Image as a link in Datagrid

Hi!
I have been struggeling for quite some time now with a stupid problem which
drives me crazy.

I have Datagrid, where I load some images from a SQL2000 database. This
works fine, but I am not abel to make the image in the datagrid to be a link
to another page.
I have created a Templeate Column for this.
Could someone be kind enough to point me in the right direction?

This is my template column:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Image id=Image1 Height="60" Width="90" ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "Image") %>' Runat="server" >
</asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
Nov 19 '05 #1
2 1820

"SQL_Klovn" <SQ******@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
Hi!
I have been struggeling for quite some time now with a stupid problem which drives me crazy.

I have Datagrid, where I load some images from a SQL2000 database. This
works fine, but I am not abel to make the image in the datagrid to be a link to another page.
I have created a Templeate Column for this.
Could someone be kind enough to point me in the right direction?

This is my template column:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Image id=Image1 Height="60" Width="90" ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "Image") %>' Runat="server" >
</asp:Image>
</ItemTemplate>
</asp:TemplateColumn>


One way is to change the image to an asp:hyperlink and provide a navigateurl
value based on the location of the page.
Mike
Nov 19 '05 #2
Hi,

One easy way you can do is to assign image's ImageUrl in
datagrid.datagrid_ItemDataBound event:

if (e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType = ListItemType.Item )
{
DataRowView drv = (DataRowView)e.Item.ItemData;
Image image = (Image)e.Item.FindConrol("Image1");
image.ImageUrl = mappingMethod(drv["Image"]); // here
you need to map phsical path to Url
}
HTH

Elton Wang
el********@hotmail.com

-----Original Message-----
Hi!
I have been struggeling for quite some time now with a stupid problem whichdrives me crazy.

I have Datagrid, where I load some images from a SQL2000 database. Thisworks fine, but I am not abel to make the image in the datagrid to be a linkto another page.
I have created a Templeate Column for this.
Could someone be kind enough to point me in the right direction?
This is my template column:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Image id=Image1 Height="60" Width="90" ImageUrl='<%#
DataBinder.Eval(Container.DataItem, "Image") %>' Runat="server" ></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>
.

Nov 19 '05 #3

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

Similar topics

1
by: Joey | last post by:
Guys, I am using multiple links in my datagrid cel which is a template column (As shown by martin in my previous post) but I am also adding an image in the anchor tag. I can see the image at...
2
by: J Sahoo | last post by:
Hi, I have a browse page where I am showing few fields from my SQL Server table. One of the field is Image type, all the fields are bound to a single table. I want to show the image from the...
3
by: Rob Rogers | last post by:
I have an ASP.NET datagrid that contains an image. The image can be one of two images, either "INFO.GIF" or "NOINFO.GIF". The datagrid looks fine when I test it from my local machine in visual...
13
by: Neo Geshel | last post by:
I have examined about 80+ different upload scripts on the 'net, both in VB and C#, and none seem to do what I need them to do. Perhaps someone here can point me somewhere that Google hasn't...
2
by: CDWaddell | last post by:
I'm trying to write some code to validate if an image is present on the server. If the image is missing then I want to display out noimage.gif file. I have a website that has thousands of...
0
by: Stephen Skinner | last post by:
Ok, I've banged my head on this as long as I care to. I'm trying to use image buttons to add nice graphical edit butons to my datagrid. The link buttons trigger the datagrid commands, but the image...
2
by: Bob | last post by:
I looked at the sample in the msdn january 2005 - Introducing a new datagrid, but the project downloaded failed to open. Any one can point me to a bit of code on how to go and select an image...
1
by: gh | last post by:
I have a datagrid and the first column is setup as hyperlink column. Each row will have a different image and link assigned to it, at runtime. Would I use the datagrid item to assign these to the...
2
by: jeenajos | last post by:
Hi all, Im working with Datagrid for image manipulation.I have an image upload part which work as uploading an image in Server Map Path and storing the image path in database .I displays the...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.