Solved

asp.net vb.net gridview image column with link

Posted on 2009-05-06
4
652 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 500 total points
ID: 24324214
Hi,

Try changing it to:

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

/Carl.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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