in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

Changing the message from: Exception has been thrown by the target of an invocation

Last post 11/20/2008 2:51 PM by Mehul Harry (Developer Express). 3 replies.
Page 1 of 1 (4 items)
Sort Posts:
Previous Next
  • 11/19/2008 9:46 AM

    Changing the message from: Exception has been thrown by the target of an invocation

     I have a function in my data access layer that reads errors or print messages return from calls to my stored procedures.  I throw an exception when a message is present and my grid them displays the "Exception has been thrown by the target of an invocation." message...  How do i change that message tot he custom message returned by my stored procedure.

    Filed under:
  • 11/19/2008 8:32 PM In reply to

    Re: Changing the message from: Exception has been thrown by the target of an invocation

    Marcos,

    You should try to catch that during debugging. Also try this thread (or google).

  • 11/20/2008 8:55 AM In reply to

    Re: Changing the message from: Exception has been thrown by the target of an invocation

    Answer

     Here's the solution:

    To roll the error into a DevExpress gridview,  you must use the ObjectDisposing event of the object data source for the grid to capture the error text.  Then use the the CustomErrorText event of the grid itself to display the message in the error row of the grid.  Make sure that you are throwing the error in the function of the data class.  It must be unhandled or the custom error event won't fire.

     

    ' In data class function:

    ' In code page

          If sErrorRollUp <> "" Then

               Throw New Exception(sErrorRollUp)    

         End If

     

    Protected Sub ObjectDataSource1_ObjectDisposing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs) Handles ObjectDataSource1.ObjectDisposing

     

    Protected Sub ASPxGridView1_CustomErrorText(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridView.ASPxGridViewCustomErrorTextEventArgs) Handles ASPxGridView1.CustomErrorText

     

         Dim err As Object = e

         err.ErrorText = Session(

     

    "businessrule_error")

     

    End Sub

     

     

     

     

     

     

     

     

     

     

        Dim objBusinessRuleException As Object = e.ObjectInstance

        Session("businessrule_error")

     End Sub

     

  • 11/20/2008 2:51 PM In reply to

    Re: Changing the message from: Exception has been thrown by the target of an invocation

    Hi Marcos,

    Thanks for posting that solution and glad that you got it resolved.

Page 1 of 1 (4 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED