使用GridView和LinqDataSource时如何捕获ChangeConflictException [英] How to catch ChangeConflictException when using GridView and LinqDataSource

查看:105
本文介绍了使用GridView和LinqDataSource时如何捕获ChangeConflictException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用LinqDataSource和GridView成功实现了乐观并发,但是当另一个用户更新记录时,我无法解决如何捕获ChangeConflictException的问题.

LinqDataSource.Updating事件似乎为时过早,LinqDatSource.Updated事件肯定为时已晚!

我是否需要在LinqDataSource.Updating事件中添加代码以手动执行更新并捕获任何错误?

I have successfully implemented optimistic concurrency using LinqDataSource and GridView, but I cannot work out how to catch the ChangeConflictException when a record is updated by another user.

The LinqDataSource.Updating event appears to be too soon and the LinqDatSource.Updated event is definitely too late!

Do I need to add code in the LinqDataSource.Updating event to manually carry out the update and catch any errors?

推荐答案



如果可能的话,您可能会看到此链接...
Hi,

You may see this link if ever could help...
Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL)




问候,

代数




Regards,

Algem


GridView.RowUpdated事件是您想要的事件;

The GridView.RowUpdated event is the one you want;

protected void BasicGridView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
    string message = "";

    if (e.Exception != null)
    {
        message = "horrible error, argh!";
        e.ExceptionHandled = true;
    }
    else message = "Save Successful!";

}


这篇关于使用GridView和LinqDataSource时如何捕获ChangeConflictException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆