Catch Delete Exception

5 posts, 0 answers
  1. Maher Khalil
    Maher Khalil avatar
    11 posts
    Member since:
    Oct 2009

    Posted 30 Jan 2010 Link to this post

    Hello

    I have the Grid Binded with Sql data source with embeded update and delete command
    i need to catch the delete or update exception generated 

    thanks
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 31 Jan 2010 Link to this post

    Hello Maher Khalil,

    Attach ItemUpdated and ItemDeleted events to radgrid and check for 'e.Exception' which indicates whether exception occured during process.

    CS:
     
        protected void RadGrid1_ItemUpdated(object source, GridUpdatedEventArgs e) 
        { 
            if (e.Exception != null
            { 
                e.ExceptionHandled = true
                Response.Write(e.Exception.Message); // Show error message 
            } 
        } 
        protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e) 
        { 
            if (e.Exception != null
            { 
                e.ExceptionHandled = true
                Response.Write(e.Exception.Message); // Show message 
            } 
        } 

    Happy coding,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Webster Velasco
    Webster Velasco avatar
    114 posts
    Member since:
    Jun 2012

    Posted 17 Jun 2010 Link to this post

    i need something like this

    but this 1 isnt working
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jun 2010 Link to this post

    Hello Webster,

    I guess you are performing data editing operations at database level with Update/Insert/Delete commands from the code-behind. In that case you can use the try-catch method directly inside the Update/Insert/Delete command for catching exception.

    Also ItemUpdated/ItemInserted/ItemDeleted events fires only when an automatic update/insert/delete operation is executed.  Hope this information helps you.

    Thanks,
    Princy.
  6. Webster Velasco
    Webster Velasco avatar
    114 posts
    Member since:
    Jun 2012

    Posted 17 Jun 2010 Link to this post

    no im performing automaticdeletes

    i have this codes:
        Private Sub DisplayMessage(ByVal text As String, ByVal grd As RadGrid) 
            grd.Controls.Add(New LiteralControl(String.Format("<span style='color:red'>{0}</span>", "<br />" & text))) 
        End Sub 
     
        Private gridMessage As String = Nothing 
        Protected Sub grdG_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles grdESCPagine.DataBound 
            If Not String.IsNullOrEmpty(gridMessage) Then 
                DisplayMessage(gridMessage, grdESCPagine) 
            End If 
        End Sub 
        Private Sub SentMessage(ByVal text As String) 
            gridMessage = text 
        End Sub 
        Protected Sub grdVal_ItemUpdated(ByVal source As Object, ByVal e As GridDeletedEventArgs) Handles grdESCPagine.ItemDeleted 
            e.ExceptionHandled = True 
            If e.Exception IsNot Nothing Then 
                SentMessage("Error on Delete : " + e.Exception.Message) 
            End If 
            If TestoMessaggio.Length > 0 Then 
                SentMessage("Error on Delete: " + TestoMessaggio) 
            End If 
        End Sub 

    but my datagrid is set to allowscrolling at client side and allowpaging=false

    w/ this set up it isnt working..

    but if i change allowpaging=true it does work
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017