vishnu suresh

vishnu suresh

  • NA
  • 53
  • 15.4k

how to set default image in asp.net

Jan 25 2015 6:11 AM
 

I have an asp.net web application in which the images from gridview is displayed on a label. I have used this code for displaying image in gridview

 

<ItemTemplate>

<img src='data:image/jpg;base64,<%# Eval("img") != System.DBNull.Value ? Convert.ToBase64String((byte[])Eval("img")) : string.Empty %>' alt="image" height="250px" width="275px"/>

</ItemTemplate>

This code is used to display the image from gridview to the label.

Label2.Text = ((ITextControl)GridView1.Rows[0].Cells[55].Controls[0]).Text;

in my gridview some image field value are null. some products not have images in the database. So how can set a default image for the label when the image is null.


Answers (9)