Condividi tramite


Proprietà DataRepeaterDataErrorEventArgs.PropertyName

Ottiene il nome della proprietà del controllo che ha generato l'errore.

Spazio dei nomi:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintassi

'Dichiarazione
Public ReadOnly Property PropertyName As String
public string PropertyName { get; }
public:
property String^ PropertyName {
    String^ get ();
}
member PropertyName : string with get
function get PropertyName () : String

Valore proprietà

Tipo: String
Nome della proprietà.

Note

L'evento di DataError consente di gestire le eccezioni generate nel codice chiamato da un controllo di DataRepeater durante le operazioni di elaborazione dati.

La proprietà di PropertyName contiene il nome della proprietà che ha provocato l'errore. Nella maggior parte dei casi, è la proprietà di Text del controllo. PropertyName può essere utilizzato per richiedere all'utente una correzione o scrivere nel log degli errori.

Esempi

Nell'esempio seguente viene illustrato come utilizzare i dati da DataRepeaterDataErrorEventArgs per visualizzare un messaggio quando un errore dati.

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;
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

DataRepeaterDataErrorEventArgs Classe

Spazio dei nomi Microsoft.VisualBasic.PowerPacks

DataError

Altre risorse

Introduzione al controllo DataRepeater (Visual Studio)