aspnet-devexpress-dot-web-f66ca15f.md
A data column that displays images located at the specified URLs.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public class GridViewDataImageColumn :
GridViewEditDataColumn
Public Class GridViewDataImageColumn
Inherits GridViewEditDataColumn
In the GridViewDataImageColumn, images are obtained from URLs contained in the bound data field. Use the PropertiesImage property to access and customize the column editor’s settings.
Images rendered in the GridViewDataImageColumn column are not exported. Handle the ExportRenderBrick event and assign the image to the ImageValue property to implement image export. Note that the ExportRenderBrick event does not fire in DataAware export mode, so you should set the export mode to WYSIWIG.
Run Demo: Export with Data Cell BandsView Example: ASPxGridView - Export images from the column of the GridViewDataImageColumn type
<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" DataSourceID="XmlDataSource1"
OnExportRenderBrick="grid_ExportRenderBrick">
<Columns>
<dx:GridViewDataTextColumn FieldName="Common_Name" Caption="Common name" />
<dx:GridViewDataTextColumn FieldName="Species_Name" Caption="Species name" />
<dx:GridViewDataImageColumn FieldName="ImagePath" Caption="Image">
<PropertiesImage>
<ExportImageSettings Width="180" Height="120" />
</PropertiesImage>
</dx:GridViewDataImageColumn>
</Columns>
<%--...--%>
</dx:ASPxGridView>
byte[] GetImageBinaryData(string relativePath) {
string path = Server.MapPath(relativePath);
return File.Exists(path) ? File.ReadAllBytes(path) : null;
}
protected void grid_ExportRenderBrick(object sender, ASPxGridViewExportRenderingEventArgs e) {
var dataColumn = e.Column as GridViewDataColumn;
if (dataColumn != null && dataColumn.FieldName == "ImagePath" && e.RowType == GridViewRowType.Data)
e.ImageValue = GetImageBinaryData(e.Value.ToString());
}
Private Function GetImageBinaryData(ByVal relativePath As String) As Byte()
Dim path As String = Server.MapPath(relativePath)
Return If(File.Exists(path), File.ReadAllBytes(path), Nothing)
End Function
Protected Sub grid_ExportRenderBrick(ByVal sender As Object, ByVal e As ASPxGridViewExportRenderingEventArgs)
Dim dataColumn = TryCast(e.Column, GridViewDataColumn)
If dataColumn IsNot Nothing AndAlso dataColumn.FieldName = "ImagePath" AndAlso e.RowType = GridViewRowType.Data Then e.ImageValue = GetImageBinaryData(e.Value.ToString())
End Sub
Object StateManager CollectionItem WebColumnBase GridViewColumn GridViewDataColumn GridViewEditDataColumn GridViewDataImageColumn
See Also