asp.net - 更新命令在动态数据详细信息 View 中不起作用

标签 asp.net entity-framework dynamic-data

我刚刚使用 Entity Framework 创建了一个非常基本的动态数据 Web 应用程序,当我单击 GridView 中的编辑命令时,打开详细信息 View ,编辑一些字段,然后单击更新链接,什么也没有发生。

我的问题是,什么可能会导致此更新不起作用,是否有任何诊断提示?

更多信息 EntityDataSource 似乎“隐藏”异常。我发现了多个导致更新或插入操作未完成的原因,但我必须使用 SQL 跟踪并捕获正在发送的命令。手动运行该命令会出现快速且可见的 SQL 错误。为什么它没有进入我的用户界面是一个谜。

最佳答案

一般来说,每当您调试或开发动态数据网站时,都应该转到 Site.master 文件并将 ScriptManager 的属性 EnablePartialRendering 设置为 false:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false"/>

这将使异常更加明显,否则由于使用更新面板包围列表/编辑/插入/详细信息/ListDetails页面模板上的DetailsView、FormViews和GridViews,这些异常似乎被掩盖了。

我认为您遇到的真正问题与错误处理和更新面板有关。在IE中调试时,您是否看到屏幕左下角有一个小感叹号?如果是这样,单击它,您将看到由于未处理的异常而发生的 javascript 错误 (Sys.WebForms.PageRequestManagerServerErrorException)。

有关此内容的更多信息,请查看 ScottGu's Blog on the topic .

@Aaron 的评论:现在捕捉他所指的错误还为时过早。我认为,在这种情况下,他想要处理 Updated 事件,因为 EntitydataSource 实际上不会抛出异常,直到它为该事件的处理程序提供运行机会:( MSDN ):

If an error occurs when changes are persisted to the data source, the Updated event is raised and the Exception property of the EntityDataSourceChangedEventArgs object is set to the returned Exception. If you handle the exception in the Updated event handler, set the ExceptionHandled property to true. This prevents the exception from being raised again. When you specify a value of false for the ExceptionHandled property, the EntityDataSource re-raises the exception.

关于asp.net - 更新命令在动态数据详细信息 View 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1261477/

相关文章:

c# - ASP.NET MVP 注入(inject)服务依赖

asp.net - 主页页脚对齐方式不正确

c# - 有没有办法覆盖部分类中属性的应用顺序?

asp.net - 动态数据 - 从 DropDownList 中选择一个表以在 GridView 中搭建支架

C++:动态访问类属性

asp.net - 使用 jQuery 对 FILE 类型的 INPUT 进行客户端验证,无需回发

c# - 如何从后面的代码打开模式?

c# - Linq to Entities 无法识别 string.Format 或串联 '+'

c# - 覆盖字符串属性问题

asp.net - Web 安装项目无法安装动态数据站点 : "the installer was interrupted"