Solved

asp.net vb.net gridview image column with link

Posted on 2009-05-06
4
642 Views
Last Modified: 2012-08-14
In a gridview how can create a link in an image field
0
Comment
Question by:rflorencio
  • 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 500 total points
ID: 24324214
Hi,

Try changing it to:

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

/Carl.

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now