rp
asked on
asp.net vb.net gridview image column with link
In a gridview how can create a link in an image field
use <asp:ImageButton>
Hi,
Please review the attached code as an example on how to format a link from a thumbnail image in a gridview.
/Carl.
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}&fullSize=True"
DataTextField="PhotoID" DataTextFormatString="<img src="DisplayImage.aspx?PhotoID={0}&fullSize=False" style="border:solid 1px #000000;" alt="Picture hosted at norrbom.nu">" 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>
ASKER
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
<img src="imagens/img1.jpg/"/>
Below img1.jpg appears a "/" and should not appear. What is wrong in my DataTextFormatString
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.