?
Solved

asp.net vb.net gridview image column with link

Posted on 2009-05-06
4
Medium Priority
?
661 Views
Last Modified: 2012-08-14
In a gridview how can create a link in an image field
0
Comment
Question by:rflorencio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 24318952
use <asp:ImageButton>
0
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 24319001
Hi,

Please review the attached code as an example on how to format a link from a thumbnail image in a gridview.

/Carl.
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" BackColor="#DFDFDF" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" DataKeyNames="PhotoID" DataSourceID="SqlDataSource1" EmptyDataText="There are no images to display." Font-Names="Arial" Font-Size="8pt" ForeColor="#3366CC" Width="800px">
    <Columns>
        <asp:HyperLinkField DataNavigateUrlFields="PhotoID" DataNavigateUrlFormatString="DisplayImage.aspx?PhotoID={0}&amp;fullSize=True"
                        DataTextField="PhotoID" DataTextFormatString="&lt;img src=&quot;DisplayImage.aspx?PhotoID={0}&amp;fullSize=False&quot; style=&quot;border:solid 1px #000000;&quot; alt=&quot;Picture hosted at norrbom.nu&quot;&gt;" Text="Thumbnail:">
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:HyperLinkField>
                    <asp:BoundField DataField="Submitted" HeaderText="Submitted:" SortExpression="Submitted" />
    </Columns>
    <PagerSettings Position="TopAndBottom" />
    <AlternatingRowStyle BackColor="White" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />
</asp:GridView>

Open in new window

0
 

Author Comment

by:rflorencio
ID: 24323844
I put DataTextFormatString = <img src=imagens/{0}/>, and apparently works for my purpose, but the html rendered in browser is :
<img src="imagens/img1.jpg/"/>  
Below img1.jpg appears a "/"       and should not appear. What is wrong in my DataTextFormatString
0
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 2000 total points
ID: 24324214
Hi,

Try changing it to:

DataTextFormatString = "<img src='imagens/{0}'>"

/Carl.

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question