Thanks that's very helpfull.
To get som ething going i have written the following code
protected void sdsComplaintStatus_Deleted(object sender,
SqlDataSourceStatusEventArgs e)
{
if (e.Exception != null)
{
e.ExceptionHandled = true;
lblNoDelete.Text = "Cannot delete, value in use";
lblNoDelete.ForeColor = System.Drawing.Color.Red;
}
}
On the basis that the only exception likely to be thrown is the user is
trying to delete a record that is in use as a foreign key in another table,
and i can make it more sophisticated once i have this up and running. Thing
is it still thorws the exception. Any ideas ?
I have written code to check for the condition before attempting the delete,
but it is a bit complex and this way would be more elegant.
"Flinky Wisty Pomm" wrote:
[color=blue]
> There's an example of handling SqlDataSource exceptions here
>
http://fredrik.nsquared2.com/viewpost.aspx?PostID=300 courtesy of the
> ever-helpful Fredrik Norméns.
>
> ObjectDataSources work in the same way.
>
> If you want much more control than that, you're getting into murky
> waters. Personally, I'd return an error code from my stored proc and
> throw a custom exception in the data layer.
>
>[/color]