.NET Framework Class Library DataRow..::.SetColumnError Method (Int32, String) Sets the error description for a column specified by index.
Namespace:
System.Data
Assembly:
System.Data (in System.Data.dll)

Syntax
Public Sub SetColumnError ( _
columnIndex As Integer, _
error As String _
)
public void SetColumnError(
int columnIndex,
string error
)
public:
void SetColumnError(
int columnIndex,
String^ error
)
member SetColumnError :
columnIndex:int *
error:string -> unit

Exceptions

Remarks
The method is used to set custom error descriptions on specified columns. You can use the ErrorProvider control to display the text of the error. To examine error descriptions, use the GetColumnError method. To determine whether any errors exist for the columns collection, use the HasErrors property. Consequently, you can use the GetColumnsInError method to retrieve all the columns with errors. If nullNothingnullptra null reference (Nothing in Visual Basic) or an empty string is passed in as the error parameter, the DataRow behaves as if no error was set and the HasErrors property will return false. To set a custom error description on the whole row, use the RowError property. To clear all errors for the columns collection, use the ClearErrors method. To set error text that applies to a whole row, set the RowError property.

Examples
The following example sets an error description for a specified DataRow.
Private Sub SetColError(ByVal row As DataRow, _
byVal columnIndex As Integer)
Dim errorString As String = "Replace this text."
' Set the error for the specified column of the row.
row.SetColumnError(columnIndex, errorString)
End Sub
Private Sub PrintColError( _
ByVal row As DataRow, byVal columnIndex As Integer)
' Print the error of a specified column.
Console.WriteLine(row.GetColumnError(columnIndex))
End Sub
private void SetColError(DataRow row, int columnIndex)
{
string errorString = "Replace this text.";
// Set the error for the specified column of the row.
row.SetColumnError(columnIndex, errorString);
}
private void PrintColError(DataRow row, int columnIndex)
{
// Print the error of a specified column.
Console.WriteLine(row.GetColumnError(columnIndex));
}

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileSupported in: 4, 3.5 SP1

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Biblioteca de clases de .NET Framework DataRow..::.SetColumnError (Método) (Int32, String) Establece la descripción de error para una columna especificada mediante un índice.
Espacio de nombres:
System.Data
Ensamblado:
System.Data (en System.Data.dll)

Sintaxis
Public Sub SetColumnError ( _
columnIndex As Integer, _
error As String _
)
public void SetColumnError(
int columnIndex,
string error
)
public:
void SetColumnError(
int columnIndex,
String^ error
)
member SetColumnError :
columnIndex:int *
error:string -> unit

Excepciones

Comentarios
El método se utiliza para establecer descripciones de error personalizadas de columnas especificadas. El control ErrorProvider se puede utilizar para mostrar el texto del error. Para examinar las descripciones de error, utilice el método GetColumnError. Para determinar si existen errores en la colección de columnas, utilice la propiedad HasErrors. Por tanto, puede utilizar el método GetColumnsInError para recuperar todas las columnas con errores. Si se pasa nullNothingnullptrreferencia null (Nothing en Visual Basic) o una cadena vacía como el parámetro error, el objeto DataRow se comporta como si no se hubiese enviado un error y la propiedad HasErrors devolverá el valor false. Para establecer una descripción de error personalizada de toda la fila, utilice la propiedad RowError. Para borrar todos los errores de la colección de columnas, utilice el método ClearErrors. Para establecer un texto de error que se aplique a toda una fila, establezca la propiedad RowError.

Ejemplos
En el ejemplo siguiente se establece una descripción de error para un DataRow especificado.
Private Sub SetColError(ByVal row As DataRow, _
byVal columnIndex As Integer)
Dim errorString As String = "Replace this text."
' Set the error for the specified column of the row.
row.SetColumnError(columnIndex, errorString)
End Sub
Private Sub PrintColError( _
ByVal row As DataRow, byVal columnIndex As Integer)
' Print the error of a specified column.
Console.WriteLine(row.GetColumnError(columnIndex))
End Sub
private void SetColError(DataRow row, int columnIndex)
{
string errorString = "Replace this text.";
// Set the error for the specified column of the row.
row.SetColumnError(columnIndex, errorString);
}
private void PrintColError(DataRow row, int columnIndex)
{
// Print the error of a specified column.
Console.WriteLine(row.GetColumnError(columnIndex));
}

Información de versión
.NET FrameworkCompatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0 .NET Framework Client ProfileCompatible con: 4, 3.5 SP1

Plataformas
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

Vea también
|