Compartir a través de


DataRepeaterDataErrorEventArgs.PropertyName Property

Gets the name of the property of the control that raised the error.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaración
Public ReadOnly Property PropertyName As String
    Get
public string PropertyName { get; }
public:
property String^ PropertyName {
    String^ get ();
}
member PropertyName : string
function get PropertyName () : String

Property Value

Type: System.String
The name of the property.

Remarks

The DataError event enables you to handle exceptions that are thrown in code that is called by a DataRepeater control during data processing operations.

The PropertyName property contains the name of the property that caused the error. In most cases, it is the Text property of the control. PropertyName can be used to prompt the user for a correction or to write to an error log.

Examples

The following example demonstrates how to use the data from a DataRepeaterDataErrorEventArgs to display a message when a data error occurs.

Private Sub DataRepeater1_DataError(
    ByVal sender As Object, 
    ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterDataErrorEventArgs
  ) Handles DataRepeater1.DataError

    Dim ErrorMsg As String
    ' Create an error string.
    ErrorMsg = "Invalid value entered for " & e.Control.Name & ". "
    ErrorMsg = ErrorMsg & e.Exception.Message
    ' Display the error to the user.
    MsgBox(ErrorMsg)
    ' Do not raise an exception.
    e.ThrowException = False
End Sub
private void dataRepeater1_DataError(object sender, 
    Microsoft.VisualBasic.PowerPacks.DataRepeaterDataErrorEventArgs e)
{
    string ErrorMsg;
    // Create an error string.
    ErrorMsg = "Invalid value entered for " + e.Control.Name + ". ";
    ErrorMsg = ErrorMsg + e.Exception.Message;
    // Display the error to the user.
    MessageBox.Show(ErrorMsg);
    // Do not raise an exception.
    e.ThrowException = false;
}

.NET Framework Security

See Also

Reference

DataRepeaterDataErrorEventArgs Class

Microsoft.VisualBasic.PowerPacks Namespace

DataError

Other Resources

Introduction to the DataRepeater Control (Visual Studio)