Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    DxGrid.GetEditContext() Method

    Returns the edit context.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    #Declaration

    C#
    public EditContext GetEditContext()

    #Returns

    Type Description
    EditContext

    The edit context if the Grid is being edited; otherwise, null.

    #Remarks

    Call this method to obtain the Grid’s edit context. This context allows you to check whether the data item was modified and its field values are valid. If the Grid is not in edit mode, the GetEditContext method returns null.

    The following code snippet checks whether the edit row has unsaved changes:

    @inject NwindDataService NwindDataService
    
    <DxGrid @ref="Grid"
            Data="Data"
            KeyFieldName="EmployeeId"
            EditModelSaving="OnEditModelSaving"
            EditMode="GridEditMode.EditRow">
        <Columns>
            <DxGridCommandColumn />
            <DxGridDataColumn FieldName="FirstName" />
            <DxGridDataColumn FieldName="LastName" />
            <DxGridDataColumn FieldName="Title" />
            <DxGridDataColumn FieldName="HireDate" />
        </Columns>
    </DxGrid>
    
    @code {
        IGrid Grid { get; set; }
        IEnumerable<object> Data { get; set; }
        NorthwindContext Northwind { get; set; }
    
        async Task OnEditModelSaving(GridEditModelSavingEventArgs e) {
            if (Grid.GetEditContext().IsModified()) {
                // Save changes to the database
            }
        }
        // ...
    }
    

    #Implements

    See Also