Monday, December 28, 2009

Load Images from binary stream in DataBase

So you have your images in a database, recorded in Binary fields.

To render them in .aspx forms, you need to call Response.xxx so all you're page will show only the image.

To fix this, you can create a gridview that uses a backup form as column (GetImage.aspx).

Download GetImage.aspx
Download GetImage.aspx.cs

In your main form, your gridview should contain a column to get the images for a specific item id:

<Columns>
  <asp:imagefield HeaderText="" dataimageurlfield="Id"
dataimageurlformatstring='~/GetImage.aspx?id={0}'
>
    <ControlStyle Width="400px" />
  </asp:imagefield>
</Columns>

Source:
http://www.netomatix.com/development/GridViewDisplayBlob.aspx

No comments:

Post a Comment