Back to Devexpress

MVCxGridViewEditingSettings.ShowModelErrorsForEditors Property

aspnetmvc-devexpress-dot-web-dot-mvc-dot-mvcxgridvieweditingsettings.md

latest3.6 KB
Original Source

MVCxGridViewEditingSettings.ShowModelErrorsForEditors Property

Specifies whether the grid displays error messages for invalid editors in the Edit Form.

Namespace : DevExpress.Web.Mvc

Assembly : DevExpress.Web.Mvc5.v25.2.dll

NuGet Package : DevExpress.Web.Mvc5

Declaration

csharp
public bool ShowModelErrorsForEditors { get; set; }
vb
Public Property ShowModelErrorsForEditors As Boolean

Property Value

TypeDescription
Boolean

true , to display error messages automatically; otherwise, false.

|

Property Paths

You can access this nested property as listed below:

Object TypePath to ShowModelErrorsForEditors
GridViewSettings

.SettingsEditing .ShowModelErrorsForEditors

| | MVCxGridView |

.SettingsEditing .ShowModelErrorsForEditors

| | MVCxGridViewProperties |

.SettingsEditing .ShowModelErrorsForEditors

|

Remarks

The grid automatically displays an error message near an editor if end users enter and submit invalid data due to the specified model validation rules. Use the ShowModelErrorsForEditors property to specify whether the grid displays error messages for invalid editors in the Edit Form. This property affects the ShowModelErrors property available for DevExpress MVC editors (e.g. TextBoxSettings.ShowModelErrors for TextBox).

csharp
settings.SettingsEditing.ShowModelErrorsForEditors = true;

To display a common error message in the error row , use the GridViewExtension.SetEditErrorText method.

Note

The GridViewExtension.SetEditErrorText method does not work when the grid is in batch edit mode.

csharp
@{
var grid = Html.DevExpress().GridView(settings => {
    settings.Name = "gvEditing";
    ...
    if (ViewData["EditError"] != null){
        grid.SetEditErrorText((string)ViewData["EditError"]);
    }
}

Concept

Validate Data

Online Demo

Grid View - Edit Modes

See Also

SetEditErrorText(String)

Grid View

MVCxGridViewEditingSettings Class

MVCxGridViewEditingSettings Members

DevExpress.Web.Mvc Namespace