Export (0) Print
Expand All

DataRow.RowError Property

Gets or sets the custom error description for a row.

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)

public string RowError { get; set; }

Property Value

Type: System.String
The text describing an error.

Uses the HasErrors property to first determine whether a DataRow contains errors.

The following example sets error text for ten rows of a table displayed in a DataGrid control.

private void SetRowErrors(DataTable table)
{
    // Set error text for ten rows.  
    for(int i = 0; i < 10; i++)
    {
        // Insert column 1 value into each error.
        table.Rows[i].RowError = "ERROR: " 
            + table.Rows[i][1];
    }
    // Get the DataSet for the table, and test it for errors.
    DataSet dataSet = table.DataSet;
    TestForErrors(dataSet);
}

private void TestForErrors(DataSet dataSet)
{
    // Test for errors. If DataSet has errors, test each table. 
    if(dataSet.HasErrors)
    {
        foreach(DataTable tempDataTable in dataSet.Tables)
        {
            // If the table has errors, then print them. 
            if(tempDataTable.HasErrors) 
                PrintRowErrs(tempDataTable);
        }
        // Refresh the DataGrid to see the error-marked rows.
        dataGrid1.Refresh();
    }
}

private void PrintRowErrs(DataTable table)
{
    foreach(DataRow row in table.Rows)
    {
        if(row.HasErrors) 
        {
            Console.WriteLine(row.RowError);
        }
    }
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft