ASPxGridView.CustomErrorText Event
Enables you to provide custom error descriptions.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
NuGet Package: DevExpress.Web
#Declaration
public event ASPxGridViewCustomErrorTextEventHandler CustomErrorText
#Event Data
The CustomErrorText event's data class is ASPxGridViewCustomErrorTextEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Error |
Gets or sets the error text.
Inherited from ASPx |
Error |
Indicates the error source.
Inherited from ASPx |
Exception |
Gets the exception.
Inherited from ASPx |
#Remarks
The CustomErrorText event occurs when any exception is raised within the ASPxGridView, and allows you to change the error text displayed by default. This can be useful if you want to localize error messages.
Use the ASPxGridCustomErrorTextEventArgs.ErrorText property to specify the error text.
The exception can be obtained via the ASPxGridCustomErrorTextEventArgs.Exception property. If the exception has been raised within the ASPxGridView.RowValidating event handler, the ASPxGridCustomErrorTextEventArgs.ErrorTextKind property returns GridErrorTextKind.RowValidate. Otherwise, it returns GridErrorTextKind.General.
#Online Example
#Example
The code sample below demonstrates how you can handle the CustomErrorText event to specify the particular error text, based on the exception type.
protected void ASPxGridView1_CustomErrorText(object sender,
DevExpress.Web.ASPxGridViewCustomErrorTextEventArgs e) {
if (e.Exception is NullReferenceException)
e.ErrorText = "NullReferenceException Text";
else if (e.Exception is InvalidOperationException)
e.ErrorText = "InvalidOperationException Text";
...
}