在DataGridView中删除一行后刷新页面时出现未处理的异常 [英] Unhandled exception when refreshing a page after deleting a row in DataGridView

查看:92
本文介绍了在DataGridView中删除一行后刷新页面时出现未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有EntityDataSource的DataGridView; DataGridView启用了删除和更新.一切正常,但是当我按F5键时,出现以下异常:

System.Data.OptimisticConcurrencyException:存储更新,插入或删除语句影响了意外的行数(0).自加载实体以来,实体可能已被修改或删除.刷新ObjectStateManager条目.

我已经花了大约一个小时的时间,试图在Google上找到解决方案,但是我显然缺少了一些东西,因为我不确定如何将这些信息扩展到有效的解决方案中,我开始觉得自己很简单.

有人可以向我解释我在想什么或做错了吗?
用简单的英语=/.

I have a DataGridView with EntityDataSource; DataGridView has deleting and updating enabled. Everything works well, but when I hit F5 key I get following exception:

System.Data.OptimisticConcurrencyException: Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

I''ve spent last hour or so trying to find a solution with Google, but I am obviously missing something as I am not sure how to transcend those information to working solution and I start to feel like a simpleton.

Can someone explain me what am I missing or doing wrong?
In simple English =/.

推荐答案

我有点不好意思,但这是 BIG "noobish"错误就我而言.

我正在以编程方式删除行(即通过不同的上下文在基础中),而不是在网格上删除它们.就这样.

愚蠢的我.
I am little embarrassed, but this was BIG "noobish" mistake on my part.

I was deleting rows programmatically (i.e. in base via different context), instead of deleting them on grid. That was it.

Silly me.


这篇关于在DataGridView中删除一行后刷新页面时出现未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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