Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]Welcome to DevExpress .NET Documentation
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Reporting
  [Expand]Chart Control
  [Collapse]Grid View
   [Expand]Product Information
    Getting Started
   [Expand]Fundamentals
   [Collapse]Concepts
    [Expand]Binding to Data
    [Expand]Data Representation Basics
    [Expand]Focus and Navigation
    [Collapse]Data Editing
      Edit Form
      Adding and Deleting Records
      Row Validation and Error Indication
      Edit Form Validation (Templates)
      Processing Custom Callbacks
      Batch Edit Mode
    [Expand]Data Shaping and Manipulation
    [Expand]Data Formatting
    [Expand]Master-Detail Relationship
     Appearance Customization
     Adaptivity
     Save and Restore Layout
    [Expand]Templates
    [Expand]Export
     Toolbars
    [Expand]ASPxGridLookup
    ASPxGridView Designer
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]Member Tables
   [Expand]ASPxGridView - Animated Images
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Row Validation and Error Indication

This topic describes how to check the validity of data entered by end-users into a data row. ASPxGridView allows you to manually validate an edited row, and display error icons for invalid fields.

Expanded Validating Rows

To implement row validation, you should handle the ASPxGridView.RowValidating event. This event is automatically raised when a row is about to be updated, and allows you to specify whether its data is valid or not. To manually force row validation, call the ASPxGridView.DoRowValidation method.

  • The event's OldValues and NewValues properties allow old and new row values to be obtained, respectively. These properties represent collections. Individual row values can be obtained via index notation or by specifying the field name. The event's IsNewRow property identifies whether or not a new row is being edited by the user.

  • If the value is invalid, use the Errors property to specify the error description text. As a result, an error icon will be displayed next to the invalid value. Pointing to the icon shows a hint with an error description.

  • Use the RowError property to specify the error text displayed within the Error Row. This row is automatically displayed below the edited row if the RowError property is set to a non-empty string.

    Use the ASPxGridBehaviorSettings.EncodeErrorHtml option to specify whether or not ASPxGridView keeps its row errors that are HTML as HTML, or strips out the HTML markers instead.

Expanded Validating Edit Cells

Data columns provide various validation settings available via the EditProperties.ValidationSettings property. This allows you to define the validation logic for individual edit cells.

For example, you can use the ValidationSettings.RequiredField property to force an editor to require input, and specify an error message if input is not received.

Expanded Example

This example demonstrates how to check the validity of data entered by end-users into a row. Validation is implemented within the ASPxGridView.RowValidating event handler. In this sample, validation fails in the cases listed below:

  • field value(s) is empty;
  • Contact Name and/or Company Name fields are set to a single character.

The ASPxGridView.HtmlRowPrepared event is handled to paint the row's contents red if the row is invalid. This event is raised for each data row when the corresponding row within the table has been created. This indicates rows within invalid data.

The ASPxGridView.StartRowEditing event is handled to display errors (if any) within the edited row when an end-user switches to an edit mode.

Expanded See Also

Is this topic helpful?​​​​​​​