GridViewDataImageColumn Class
A data column that displays images located at the specified URLs.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
Declaration
Remarks
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
.
<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());
}
Implements
Inheritance
See Also