Solved

asp.net vb.net gridview image column with link

Posted on 2009-05-06
4
644 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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