Skip to main content

ASPxGridView.CustomUnboundColumnData Event

Enables you to supply data to unbound columns.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web


public event ASPxGridViewColumnDataEventHandler CustomUnboundColumnData

Event Data

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

Property Description
Column Gets the unbound column currently being processed.
IsGetData Gets whether you should provide data for the currently processed cell. Inherited from ASPxGridColumnDataEventArgs.
IsSetData Gets whether the cell’s value should be stored in a custom data source. Inherited from ASPxGridColumnDataEventArgs.
ListSourceRowIndex Gets the current data item’s (row, card or record) index in the data source. Inherited from ASPxGridColumnDataEventArgs.
Value Gets or sets the value of the cell currently being processed. Inherited from ASPxGridColumnDataEventArgs.

The event data class exposes the following methods:

Method Description
GetListSourceFieldValue(Int32, String) Returns the value of the specified field in the specified data item (row, card or record) in the control’s underlying data source. Inherited from ASPxGridColumnDataEventArgs.
GetListSourceFieldValue(String) Returns the value of the specified cell in the processed data item (row, card or record) in the control’s underlying data source. Inherited from ASPxGridColumnDataEventArgs.



The CustomUnboundColumnData event fires for unbound columns only.

Add a new data column to the ASPxGridView.Columns collection and set its GridViewDataColumn.UnboundType property to an appropriate value to create an unbound column. This column’s GridViewDataColumn.FieldName property value must be unique and it must not refer to any field in the ASPxGridView’s underlying data source.

When the ASPxGridView is loaded, it raises the CustomUnboundColumnData event for each cell in unbound columns. This allows you to populate cells with data. By default, the event’s ASPxGridColumnDataEventArgs.IsGetData parameter is set to true. In this case, you need to supply data for the currently processed cell. Obtain the required value from a custom data source and assign it to the ASPxGridColumnDataEventArgs.Value parameter.

The event’s ASPxGridColumnDataEventArgs.IsSetData parameter isn’t in effect. Handle the ASPxGridView.RowUpdating event to save the modified data back to the data source.

Use the ASPxGridViewColumnDataEventArgs.Column and ASPxGridColumnDataEventArgs.ListSourceRowIndex properties to identify a row and column to which the currently processed cell belongs.

The CustomUnboundColumnData event argument provides the ASPxGridColumnDataEventArgs.GetListSourceFieldValue method that allows you to get the required cell value.


Unbound Columns

Online Example

View Example: How to calculate templated column values on the client


<dx:ASPxGridView ID="Grid" ClientInstanceName="Grid" runat="server" AutoGenerateColumns="false"
        DataSourceID="ProductsDataSource" KeyFieldName="OrderID" OnInit="Grid_Init" OnCustomUnboundColumnData="Grid_CustomUnboundColumnData">
        <SettingsPager PageSize="5" />
            <dx:GridViewDataTextColumn FieldName="ProductName" />
            <dx:GridViewDataSpinEditColumn FieldName="UnitPrice" >
                <PropertiesSpinEdit DisplayFormatString="c" DecimalPlaces="2" />
            <dx:GridViewDataSpinEditColumn FieldName="Quantity" >
            <dx:GridViewDataSpinEditColumn FieldName="Discount" >
                <PropertiesSpinEdit DisplayFormatString="p0"></PropertiesSpinEdit>
<ef:EntityDataSource runat="server" ID="ProductsDataSource" ContextTypeName="DevExpress.Web.Demos.NorthwindContext" EntitySetName="Invoices" />
using DevExpress.Web.ASPxGridView;

protected void Grid_Init(object sender, EventArgs e) {
    // Creates a column, customizes its settings, and appends it to the Columns collection.
    GridViewDataTextColumn colTotal = new GridViewDataTextColumn();
    colTotal.FieldName = "Total";
    colTotal.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
    colTotal.VisibleIndex = Grid.VisibleColumns.Count;
    colTotal.PropertiesTextEdit.DisplayFormatString = "c2";
// Populates the unbound column.
protected void Grid_CustomUnboundColumnData(object sender,
    ASPxGridViewColumnDataEventArgs e) {
    if (e.Column.FieldName == "Total") {
        decimal unitPrice = Convert.ToDecimal(e.GetListSourceFieldValue("UnitPrice"));
        int quantity = Convert.ToInt32(e.GetListSourceFieldValue("Quantity"));
        decimal discount = Convert.ToDecimal(e.GetListSourceFieldValue("Discount"));
        e.Value = unitPrice * quantity * (1 - discount);
See Also