如何从ObjectDataSource.Delete方法访问返回对象以在ObjectDataSource.Deleted方法中使用?

时间:2019-02-15 21:28:32

标签: objectdatasource

在aspx页面上配置ObjectDataSource对象时,我选择了名为EntryData的业务对象。然后,我选择了自定义DeleteEntry()方法来与DELETE操作关联。配置对话框指示我的DeleteEntry()方法返回了我类型为BteResponse的业务对象: DeleteEntry(String sequenceNum),返回了BteResponse

这是我在aspx页面上的ObjectDataSource定义:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        InsertMethod="createEntry"
        SelectMethod="getEntries"
        TypeName="BTEMaxApp.BusinessLogic.EntryData"
        OnInserted="ObjectDataSource1_Inserted" 
        OldValuesParameterFormatString="original_{0}" 
        DeleteMethod="DeleteEntry" 
        OnDeleted="EntryDeleted"
        UpdateMethod="UpdateEntry">

这是我与DeleteMethod事件关联的自定义DeleteEntry()方法:

public BTESvcRef.BteResponse DeleteEntry(string sequenceNum)
    {
        BTESvcRef.EntriesClient client = new BTESvcRef.EntriesClient(_BTESvcRefEndpoint);
        BTESvcRef.BteResponse response = new BTESvcRef.BteResponse();
        BTESvcRef.BteFileRequest request = new BTESvcRef.BteFileRequest();

        request.FileName = HttpContext.Current.Session[Constants.SessionBTEName].ToString();
        request.SequenceNumber = sequenceNum;
        request.ServicePassword = bteServicePassword;
        request.UserId = HttpContext.Current.Session[Constants.SessionUserName].ToString();
        response = client.DeleteBteFile(request);

        if (!response.Error)
        {
            //some code here
        }
        else
        {
            //some code here
        }                       

        return response;
    }

接下来,我想利用ObjectDataSource的OnDeleted事件运行我的DeletedEntry()方法,以确保从DeleteEntry()返回的响应对象不包含错误。

 public void EntryDeleted(object source, ObjectDataSourceStatusEventArgs e)
    {
        //I want to be able to check the returned response object here 
        //so that I can proceed if there was no error on the actual delete
        //else, display an error message to the user       
    }

如何访问EntryDeleted()中DeleteEntry()返回的响应对象?

0 个答案:

没有答案