Displayed linked picture in Gridview RRS feed

  • Question

  • User876561910 posted


    Let’s say I have a database with:


    For example
    Place_ID = 123
    Place_Name = Everest
    Place_picture = https://commons.wikimedia.org/wiki/File:Everest_kalapatthar.jpg#/media/File:Everest_kalapatthar.jpg


    Place_ID = 465
    Place_Name = Grand Canyon
    Place_picture = https://commons.wikimedia.org/wiki/File:Nankoweap.JPG#/media/File:Nankoweap.JPG

    How do I get this linked to picture to show in the grid view Or I could save the picture to a folder in the website, how would I show this (but I would rather just link to wikipeadia)

    I show this on a Gridview like this (the picture is not showing obviously)


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Page Language="C#" %>
    <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta content="en-gb" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    <form id="form1" runat="server">
    		<asp:GridView id="gridview1" runat="server" allowpaging="True" AllowSorting="True" 
    			<asp:boundfield DataField="Place_Name">
    			<asp:boundfield DataField="Place_picture">
    		<asp:AccessDataSource ID="some_name" runat="server" DataFile="myDatabase.mdb" SelectCommand="SELECT [Place_Name], [Place_picture] FROM [my_table]">

    Friday, March 29, 2019 2:12 PM


  • User-1038772411 posted

    You can try below code to display image in GridView which stored as a link in database. I have used simple HTML img tag to display image.

    <asp:GridView ID="gvImages" CssClass="Gridview" runat="server" AutoGenerateColumns="False"
    HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="white">
    <asp:BoundField HeaderText = "Image Name" DataField="ImageURL" />
    <asp:TemplateField HeaderText="Image">
    <img src='<%# Eval("ImageURL") %>' Height="150" Width="150" />

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 29, 2019 2:20 PM