Question: > 
> **Possible Duplicate:**  
> 
> [How to show a image in database in the image control of Asp.net?](https://stackoverflow.com/questions/2482104/how-to-show-a-image-in-database-in-the-image-control-of-asp-net) 
> 
> 
> 

I am returning a list of products from a database. Inside this list i am saving database images as bytearrays. Currently I am displaying about 30 products on a page and i would like to add their images next to the product information. What would be the easiest way to go about this?

What I have:

```
public Image PopulatePicture()
{
    Image newImage;
    //Read image data into a memory stream
    using (MemoryStream ms = new MemoryStream(ImageByteArray, 0, ImageByteArray.Length))
    {
        ms.Write(ImageByteArray, 0, ImageByteArray.Length);

        //Set image variable value using memory stream.
        newImage = Image.FromStream(ms, true);
    }
    return newImage;
}

```

I have an error on Image.FromStream (System.Web.UI.WebControls does not contain a definition for FromStream)

Answer: 
You likely have a few issues here:

1. You are referencing an asp.net Image object (`System.Web.UI.WebControls.Image`) not the GDI+ `System.Drawing.Image` object that you want. Clarify your namespace.
2. You can't dispose the stream on the image. Drop the using block. <https://stackoverflow.com/a/13696705/64262>
3. You will need to write the resulting stream to the response stream (negating the need to convert it to an image in the first place), and then reference that endpoint from an `<img>` tag.
A generic ASP.NET Handler (\*.ashx) could load the image from the database and stream it as a normal image to the browser. 

May this <http://coffeedrivendevelopment.net/2012/10/26/sharing-image-resources-between-wpf-and-asp-net/> will help you. It is about images in ressources, but the way is the same.