共用方式為


DataRepeater.DataError Event

Occurs when an external data-parsing or validation operation throws an exception, or when an attempt to commit data to a data source fails.

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

Syntax

'宣告
Public Event DataError As DataRepeaterDataErrorEventHandler
public event DataRepeaterDataErrorEventHandler DataError
public:
 event DataRepeaterDataErrorEventHandler^ DataError {
    void add (DataRepeaterDataErrorEventHandler^ value);
    void remove (DataRepeaterDataErrorEventHandler^ value);
}
member DataError : IEvent<DataRepeaterDataErrorEventHandler,
    DataRepeaterDataErrorEventArgs>
JScript does not support events.

Remarks

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

For more information about how to handle events, see Consuming Events.

Examples

The following code example demonstrates a DataError event handler.

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

DataRepeater Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

Introduction to the DataRepeater Control (Visual Studio)