ExceptionHandled

 protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        if (e.Exception != null)
        {
            ErrorMessageLabel.Text = "Failed to DELETE due to foreign key contstraint on the table.  You may only delete rows which have no related records.";
            e.ExceptionHandled = true;
        }
    }

C#
public bool ExceptionHandled { get; set; }

属性值

如果异常已在事件处理程序中得到处理,则为 true;否则为 false。默认为 false

当删除操作过程中引发异常时,可使用 ExceptionHandled 属性指示该异常是否已在事件处理程序中得到处理。如果将此属性设置为 true,则该异常被视为已处理,而不会在调用堆栈上进一步传递。如果将此属性设置为 false,该异常就会传递到调用堆栈上的下一个方法以进行处理。若要确定引发了哪个异常,请使用 Exception 属性。

posted on 2007-12-10 22:33  Scott Jin  阅读(355)  评论(0编辑  收藏  举报

导航