Hide show image based on Database column value in ASP.Net

Last Reply on Apr 21, 2017 05:22 AM By micah

Posted on Apr 20, 2017 09:01 AM

How do i do this

If this the image column in database is empty hide this image from page

 

 <asp:Image ID="Image3" runat="server" class="" Style="width: 100%" ImageUrl='<%# "UserImage/"+Eval("ImageName1")%>' />                                       

 

Posted on Apr 21, 2017 04:45 AM Modified on on Apr 21, 2017 06:11 AM

Hi micah,

Please use below code.

<asp:Image Visible='<%# (Eval("ImageName1").ToString()== "null") || (Eval("ImageName1").ToString() == String.Empty) ? false :true %>'
ID="Image4" runat="server" Width="100px" ImageUrl='<%# Eval("ImageName1") %>'
GenerateEmptyAlternateText="True" EnableViewState="False" />