2

アホイ!

ObjectDataSource にバインドされた ASP.NET GridView コントロールを使用しています。

<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>

CommandName="Update" で ImageButton コントロールをクリックすると、指定された OnUpdating イベントが発生しますが、指定された UpdateMethod または OnUpdated イベントは発生しません。

<EditItemTemplate>
    <asp:ImageButton ID="ImageButton_Save" runat="server"
        CommandName="Update"
        SkinID="Save"
        CausesValidation="false"
        CommandArgument='<%# Eval("Id") %>' />
    <asp:ImageButton ID="ImageButton_Cancel" runat="server"
        CommandName="Cancel"
        SkinID="Cancel"
        CausesValidation="false" />
</EditItemTemplate>

入力パラメーターは、OnUpdating イベントで次のように定義されます。

protected void Things_Updating(object sender, ObjectDataSourceMethodEventArgs e)
{
    e.InputParameters["thing"] = _theThing;
}

例外はスローされません。ページは、EditItemTemplate コントロールが表示されたままポスト バックされます。あらゆる場所にブレークポイントを配置できますが、トレイルは Things_Updating の最後で停止します。デバッガーによって処理またはキャッチされない例外が発生しているようです。ボンネットを開いて、ASP.NET が何をしているか (または何をしていないか) を確認する方法はありますか?

前もって感謝します!

4

2 に答える 2

2

BLL.Thing.UpdateThing()実行しますか?これは後で発生しThings.Updating、簡単にデバッグできます。また、何か例外が発生している場合は、おそらくそれが原因です。

編集:

GridView.RowUpdatingの代わりにのハンドラーにパラメーターを追加してみてくださいObjectDataSource.Updating。それが私が通常行う方法です。のイベントDataSourceViewで更新パラメータを変更するには、 を取得する必要があると思います。ObjectDataSource(参照: ObjectDataSource Gridview Insert が空の値ディクショナリで失敗する)

protected void gridThings_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    e.NewValues.Add("thing", _theThing);
}
于 2011-12-19T21:00:12.500 に答える
1

Two things come to mind that could cause the progress to stop right there:

  1. You've handled he GridView.RowUpdating event as well, and set the GridViewUpdateEventArgs.Cancel property to true. Something like this:

    protected void myGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e)
    {
        e.Cancel = true;
    }
    
  2. You've done something similar in the ObjectDataSource.Updating event, setting the ObjectDataSourceMethodEventArgs.Cancel property to false. Like this:

    private void myObjectDataSource_Updating(object source, ObjectDataSourceMethodEventArgs e)
    {
        e.Cancel = true;
    }
    

Either of these will halt the update process, causing something like what you're describing.

于 2011-12-20T14:39:09.167 に答える