Skip to main content
Tab

ASPxGridView.ExportRenderBrick Event

Allows you to customize an exported grid element.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

public event ASPxGridViewExportRenderingEventHandler ExportRenderBrick

Event Data

The ExportRenderBrick event's data class is ASPxGridViewExportRenderingEventArgs. The following properties provide information specific to this event:

Property Description
BrickStyle Gets the style settings used to paint report bricks.
Column Gets a data column that corresponds to the processed grid element.
ImageValue Gets or sets an array of bytes that contains the processed brick’s image.
KeyValue Gets the processed row’s key.
RowType Gets the processed row’s type.
Text Gets or sets the text displayed within the brick currently being rendered.
TextValue Gets or sets the processed brick’s value.
Url Gets or sets the rendered brick’s URL.
Value Gets the processed data cell’s value.
VisibleIndex Gets the processed row’s visible index.
XlsExportNativeFormat Specifies the format settings that are applied to a document when it is exported to XLS format.
XlsxFormatString Specifies the format string applied to the processed brick’s value when exporting to Excel format (XLS or XLSX).

The event data class exposes the following methods:

Method Description
GetValue(String) Returns the value of the specified cell within the processed row.

Remarks

Handle the ExportRenderBrick event to customize an exported grid element, for instance, color grid cells or export images contained in a 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());
}

View Example: How to export images from the column of the GridViewDataImageColumn type View Example: How to export a colored grid in WYSIWYG export mode

Limitation

The ExportRenderBrick event does not fire in DataAware export mode. Use the XlsExportOptionsEx.CustomizeCell or XlsxExportOptionsEx.CustomizeCell event instead.

See Also