What is the beat way to intercept this SQLException, stop processing and display the error message when using the standard Gridview features. Currently the best I can see is by using something similar to:
Protected Sub gv_OnRowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs)
Catch ex As System.Data.SqlClient.SqlException
some delete code here... Would expect a reference to the standard Gridview delete process somehow...
If ex.Number = 547 Then 'handle foreign key violation(547)
lblMsg.Text = "Record cannot be deleted as it is being used by other tables."
I guess there must be a very standard way of achieving this.
I am using ASP.NET2 and SQL Server 2005.
Thanks in advance,