Grid View for ASP.NET Web Forms - How to use ASPxBinaryImage to bind a field that contains image data stored as OLE objects
If your data source contains images in a custom format (for instance, OLE Objects), the ASPxGridView control cannot bind data automatically. Follow the steps below to display the images in the grid:
- Create DataItemTemplate for an image column.
- Place the ASPxBinaryImage control in the template.
- Write a function to transform images from your format to an array of bytes.
- Use a custom binding expression to bind the ASPxBinaryImage.Value property to the transformed data.
<dx:GridViewDataTextColumn Caption="Image" FieldName="Image" >
<DataItemTemplate>
<dx:ASPxBinaryImage ID="ASPxBinaryImage1" runat="server"
Value='<%# ConvertOleObjectToByteArray(Eval("Image")) %>' />
</DataItemTemplate>
</dx:GridViewDataTextColumn>
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
(you will be redirected to DevExpress.com to submit your response)