C# 调试GridView/ObjectDataSource事件
啊 我正在使用绑定到ObjectDataSource的ASP.NET GridView控件:C# 调试GridView/ObjectDataSource事件,c#,asp.net,objectdatasource,edititemtemplate,C#,Asp.net,Objectdatasource,Edititemtemplate,啊 我正在使用绑定到ObjectDataSource的ASP.NET GridView控件: <asp:ObjectDataSource ID="Things" runat="server" TypeName="BLL.Thing" UpdateMethod="UpdateThing" OnUpdating="Things_Updating" OnUpdated="Things_Updated"> <UpdateParameters>
<asp:ObjectDataSource ID="Things" runat="server"
TypeName="BLL.Thing"
UpdateMethod="UpdateThing"
OnUpdating="Things_Updating"
OnUpdated="Things_Updated">
<UpdateParameters>
<asp:SessionParameter
Name="userContext"
SessionField="UserContext"
Type="Object" />
<asp:Parameter Name="thing" Type="Object" />
</UpdateParameters>
</asp:ObjectDataSource>
没有抛出异常。页面刚刚发回,EditItemTemplate控件仍在显示。我可以把断点放得到处都是,但是跟踪会在事情结束时停止。似乎发生了调试器无法处理或捕获的异常。有没有办法打开引擎盖,看看ASP.NET正在做什么(或没有做什么)
提前谢谢 是否执行
BLL.Thing.UpdateThing()
?这应该发生在事件之后。更新并且易于调试。另外,如果有什么东西导致异常,那很可能就是它
编辑:
尝试在处理程序中为GridView.RowUpdating
而不是ObjectDataSource.Updating
添加参数。我通常就是这样做的。我认为您需要获取DataSourceView
来修改ObjectDataSource
事件中的更新参数。(见:)
我想到了两件事,这可能导致进展就此停止:
您还处理了GridView.rowUpdate
事件,并将GridViewUpdateEventArgs.Cancel
属性设置为true。大概是这样的:
protected void myGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e)
{
e.Cancel = true;
}
您在ObjectDataSource.updateing
事件中做了类似的操作,将ObjectDataSourceMethodEventArgs.Cancel
属性设置为false。像这样:
private void myObjectDataSource_Updating(object source, ObjectDataSourceMethodEventArgs e)
{
e.Cancel = true;
}
这两个选项中的任何一个都会停止更新过程,导致类似于您所描述的情况。不,在事物更新之后,跟踪会神秘地结束:-/我认为GridView类没有onUpdate事件,但它确实有一个RowCommand事件,我将使用它。谢谢@亚当:我错了,我想引用GridView.rowUpdate
。谢谢你的接受!谢谢,伙伴。我有条件逻辑,在某些情况下将e.Cancel设置为true,但它们没有被命中。我将放弃这种方法,而是在RowCommand事件中使用我自己的方法。@Adam Well shoot!那么祝你好运=)
protected void gridThings_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
e.NewValues.Add("thing", _theThing);
}
protected void myGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e)
{
e.Cancel = true;
}
private void myObjectDataSource_Updating(object source, ObjectDataSourceMethodEventArgs e)
{
e.Cancel = true;
}