Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display an image from a link in an ASP.Net GridView

I've saw ways to display binary images in a gridView - using repeaters, for example. I'm curious - how would you display an image which is stored as a link (i.e: https://s-media-cache-ak0.pinimg.com/736x/ee/dc/cb/eedccb62388bb15b8ba6564372c71bac.jpg) in a database? Is there any efficient, simple way to do it if I put the dataset source into the gridview (not using an imageField)?

like image 787
A. Abramov Avatar asked Nov 22 '25 04:11

A. Abramov


1 Answers

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">
 <Columns>
    <asp:BoundField HeaderText = "Image Name" DataField="ImageURL" />
    <asp:TemplateField HeaderText="Image">
    <ItemTemplate>
       <img src='<%# Eval("ImageURL") %>' Height="150" Width="150" />
    </ItemTemplate>
    </asp:TemplateField>
 </Columns>
</asp:GridView>
like image 84
Keval Gangani Avatar answered Nov 24 '25 17:11

Keval Gangani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!