asp.net.ph

DataRow.HasErrors Property

System.Data Namespace   DataRow Class


Checks whether there are errors in a row.

Syntax


Script [ boolean var = ] DataRow.HasErrors

Property Value

This property returns only a boolean value: true if the row contains an error; otherwise, false.

The property is read only with no default value.

Remarks

When validating data, you can set an error on any column in a row.

Use SetColumnError to set an error on any column.

Use the GetColumnError and GetColumnsInError methods to return columns with errors.

The ClearErrors method clears all errors for the row.

Example

The following example first uses the HasErrors property to check for errors. If the row has errors, the GetColumnsInError method returns the array of columns with errors which can then be resolved. The ClearErrors method is then called to clear all errors.

private void GetAllErrs ( DataRow myRow ) {
   // check if the row has errors
   if ( myRow.HasErrors ) {
      // get the array of columns in error.
      DataColumn [ ] colArr = myRow.GetColumnsInError ( );

     for ( int i = 0; i < colArr.Length; i++ ) {
         // insert code to fix errors on each column.
         Response.Write ( colArr [ ].ColumnName );
      }
      // clear errors after reconciling.
      myRow.ClearErrors ( );
   }
}
  C# VB

See Also

DataRow Members   ClearErrors   ColumnsCollection   GetColumnError   GetColumnsInError   SetColumnError Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph