Compartir a través de


DataRepeaterDataErrorEventArgs.ThrowException Property

Gets or sets a value that indicates whether to throw an exception after code execution exits the DataError event handler.

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

Syntax

'Declaration
Public Property ThrowException As Boolean
public bool ThrowException { get; set; }
public:
property bool ThrowException {
    bool get ();
    void set (bool value);
}
member ThrowException : bool with get, set
function get ThrowException () : boolean 
function set ThrowException (value : boolean)

Property Value

Type: System.Boolean
true if the exception is thrown; otherwise, false. The default is false.

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 ThrowException property can be used to raise an Exception if the data error is not corrected by the user.

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)