This is a migrated thread and some comments may be shown as answers.

Catch Delete Exception

4 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maher Khalil
Top achievements
Rank 1
Maher Khalil asked on 30 Jan 2010, 02:14 PM
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

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Feb 2010, 05:38 AM
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.
0
Webster Velasco
Top achievements
Rank 2
answered on 17 Jun 2010, 11:49 AM
i need something like this

but this 1 isnt working
0
Princy
Top achievements
Rank 2
answered on 17 Jun 2010, 01:15 PM
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.
0
Webster Velasco
Top achievements
Rank 2
answered on 17 Jun 2010, 01:23 PM
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
Tags
Grid
Asked by
Maher Khalil
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Webster Velasco
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or