Skip to main content
Tab

ASPxGridView.CellEditorInitialize Event

Occurs after a cell editor contained in the edit cells is initialized, but before it’s shown.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

public event ASPxGridViewEditorEventHandler CellEditorInitialize

Event Data

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

Property Description
Column Gets the data column whose cell editor is being initialized.
Editor Gets the editor currently being processed. Inherited from ASPxGridEditorEventArgs.
KeyValue Gets the row key value - an object that uniquely identifies the row.
Value Gets the editor’s value. Inherited from ASPxGridEditorEventArgs.
VisibleIndex Gets the edited row’s visible index.

Remarks

When the Grid switches a row to edit mode, it sends a callback request to the server to initialize cell editors. Handle the CellEditorInitialize event to customize an editor’s settings before it is shown in the edit cell.

The CellEditorInitialize event is raised when an editor is created. The control hierarchy can be recreated several times during a request. As the result of the hierarchy recreation, the editor is also recreated, and this event can be raised several times.

Example 1

The following code sample demonstrates how to focus a column’s editor when it is initialized:

protected void ASPxGridView1_CellEditorInitialize(object sender,
    DevExpress.Web.ASPxGridViewEditorEventArgs e) {
    if (e.Column.FieldName == "TimeFrom") {
        e.Editor.Focus();
    }
};

Example 2

The following code sample demonstrates how to prevent a user from changing the unit price.

protected void ASPxGridView1_CellEditorInitialize(object sender,
    DevExpress.Web.ASPxGridViewEditorEventArgs e) {
    if (ASPxGridView1.IsNewRowEditing) return;
    if (e.Column.FieldName == "UnitPrice")
        e.Editor.ReadOnly = true;
}

Limitations

  • The CellEditorInitialize event does not fire in Batch edit mode because in this mode, requests are not sent to the server when an editor is activated.
  • The CellEditorInitialize event affects only the grid edit mode settings (when editors are visible).
  • The CellEditorInitialize event fires only for built-in column editors and does not fire for custom editors defined in templates.
See Also