Skip to main content

Formatting with Events

  • 4 minutes to read

ASPxGridView has three events that allow you to display custom text for individual group rows, data, and summary cells.

CustomColumnDisplayText Event

The ASPxGridView.CustomColumnDisplayText event allows you to define custom display text for any cell.


This example demonstrates how to display the “empty” string within the Units On Order column’s cells if they contain zero values.

The image below shows the result:


protected void ASPxGridView2_CustomColumnDisplayText(object sender,
    DevExpress.Web.ASPxGridViewColumnDisplayTextEventArgs e) {
    if (e.Column.FieldName != "UnitsOnOrder") return;
    if (Convert.ToInt32(e.Value) == 0)
        e.DisplayText = "empty";

CustomGroupDisplayText Event

The ASPxGridView.CustomGroupDisplayText event allows you to specify custom content for individual group rows.


This example demonstrates how to implement custom grouping. The data is grouped by the ‘Unit Price’ column, and the column’s rows that have values between 0 and 10 are combined into a single group. Rows whose values fall between 10 and 20 are combined into another group, etc.

The ‘Unit Price’ column’s GridDataColumnSettings.SortMode property is set to ‘Custom’, and the ASPxGridView.CustomColumnGroup and ASPxGridView.CustomColumnSort events are handled identically.

Additionally, the ASPxGridView.CustomGroupDisplayText event is handled to replace the default text displayed within group rows.

The image below shows the result.



Refer to the following online example to review how the custom group feature works: How to implement custom grouping logic for ASPxGridView columns.

<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" 
    DataSourceID="AccessDataSource1" KeyFieldName="ProductID" 

        <dx:ASPxSummaryItem SummaryType="Count" />

        <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" 
            <EditFormSettings Visible="False" />
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1">

        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="2" 
            GroupIndex="0" SortIndex="0" SortOrder="Ascending">
            <PropertiesTextEdit DisplayFormatString="c">
            <Settings AllowDragDrop="False" SortMode="Custom" />

        <dx:GridViewDataCheckColumn FieldName="Discontinued" VisibleIndex="3">

    <Settings ShowGroupedColumns="True" ShowGroupPanel="True" />
protected void ASPxGridView1_CustomColumnSort(object sender, DevExpress.Web.ASPxGridView.CustomColumnSortEventArgs e){

protected void ASPxGridView1_CustomColumnGroup(object sender, DevExpress.Web.ASPxGridView.CustomColumnSortEventArgs e){

private void CompareColumnValues(DevExpress.Web.ASPxGridView.CustomColumnSortEventArgs e) {
    if (e.Column.FieldName == "UnitPrice"){
        int res = 0;

        double x = Math.Floor(Convert.ToDouble(e.Value1) / 10);
        double y = Math.Floor(Convert.ToDouble(e.Value2) / 10);
        res = Comparer.Default.Compare(x, y);
        if (res < 0) res = -1;
        else if (res > 0) res = 1;
        if (res == 0 || (x > 9 && y > 9)) res = 0;

        e.Result = res;
        e.Handled = true;

protected void ASPxGridView1_CustomGroupDisplayText(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDisplayTextEventArgs e){
    if (e.Column.FieldName == "UnitPrice"){
        double d = Math.Floor(Convert.ToDouble(e.Value) / 10);
        string displayText = string.Format("{0:c} - {1:c} ", d * 10, (d + 1) * 10);
        if (d > 9) displayText = string.Format(">= {0:c} ", 100);
        e.DisplayText = displayText;

SummaryDisplayText Event

The ASPxGridView.SummaryDisplayText event allows you to specify custom display text for any total or group summary value.