473,657 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:TemplateCo lumn>
<ItemTemplate >
<asp:Image id=Image1 Height="60" Width="90" ImageUrl='<%#
DataBinder.Eval (Container.Data Item, "Image") %>' Runat="server" >
</asp:Image>
</ItemTemplate>
</asp:TemplateCol umn>
Nov 19 '05 #1
2 1826

"SQL_Klovn" <SQ******@discu ssions.microsof t.com> wrote in message
news:64******** *************** ***********@mic rosoft.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:TemplateCo lumn>
<ItemTemplate >
<asp:Image id=Image1 Height="60" Width="90" ImageUrl='<%#
DataBinder.Eval (Container.Data Item, "Image") %>' Runat="server" >
</asp:Image>
</ItemTemplate>
</asp:TemplateCol umn>


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.datagr id_ItemDataBoun d event:

if (e.Item.ItemTyp e == ListItemType.Al ternatingItem ||
e.Item.ItemType = ListItemType.It em )
{
DataRowView drv = (DataRowView)e. Item.ItemData;
Image image = (Image)e.Item.F indConrol("Imag e1");
image.ImageUrl = mappingMethod(d rv["Image"]); // here
you need to map phsical path to Url
}
HTH

Elton Wang
el********@hotm ail.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:TemplateC olumn>
<ItemTemplat e>
<asp:Image id=Image1 Height="60" Width="90" ImageUrl='<%#
DataBinder.Eva l(Container.Dat aItem, "Image") %>' Runat="server" ></asp:Image>
</ItemTemplate>
</asp:TemplateCol umn>
.

Nov 19 '05 #3

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

Similar topics

1
1059
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 design time but not when the page is loaded. Can someone please tell me what I am doing wrong
2
2693
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 table on this browse along with the other fields. Here is the code what I have from the HTML view, I am using a datagrid to show the result. It does not show the image rather it shows "System.Byte " on the output. I did not have any code behind...
3
1583
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 studio.net, but when I publish it to the net, the "INFO.GIF" image doesn't show up. I am pulling my hair out on this one. Here is the code from my aspx file. <asp:templateColumn> <itemtemplate>
13
2345
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 reached yet (I have gone all the way to page 50 on Google's results!!). Here are my requirements: • I have a DataGrid. Everything will be done from here. Everything. No exceptions. Everything will also be done in VB, without any code-behind to...
2
1752
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 products with thousands of images for those products. Here's a page with two missing images. http://dep.teamattire.com/Store/default.aspx?CatID=31&TeamID=45&SubCatID=75 Many of the images come from other webservers. We do not have the images...
0
1151
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 buttons will not. Has anyone seen this behavior before? What am I missing? I know it can be done because I have seen it done before. I would assume that the image button would work just like the link button, but I must be missing something. At...
2
2279
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 that will get put in the datagridview. The column is bound to a sql server 2005 image data field. I just need to know how to put the image in the column. Any help appreciated. Bob
1
1000
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 hyper link properties at runtime? Thanks
2
1422
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 image name in datagrid. The thing i want is, hw can i display the image in a placeholder wen i click that link in Datagrid? Can anyone suggest an idea.?Is there any other option?Whether this concept works? And also is it possible to return a value...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8509
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.