ObjectDataSource does not call the Insert method when it has additional parameters

I am new to ASP.NET and I am trying to implement a native ObjectDataSource insertion method. The default business method works fine (with one object parameter). However, when I add an additional parameter, the business method is not called.

Here is my code - Insert () is always called, but InsertWithParams () never does.

// Business Layer 
public class MyObject
{
  public MyObject() {}
  public string Foo { get; set;}
}

namespace MyLogic {
public static Insert(MyObject m)
{
  // ... do DB insert
}

public static InsertWithParams(MyObject m, string p)
{
  // ... do more fancy DB insert
}
} // MyLogic

Given the following ObjectDataSource declaration, InsertWithParams and MyObjectDS_Inserting are never called.

However, if "MyLogic.Insert" is specified instead, it raises a call along with the event. Also, if I remove the p parameter from InsertWithParams, it will be called.

<asp:ObjectDataSource runat="server" ID="MyObjectDS"
        TypeName="Business.MyLogic"
        DataObjectTypeName="Business.MyObject"
        InsertMethod="InsertWithParams"
        OnInserting="MyObjectDS_Inserting"
        >
        <InsertParameters>
            <asp:Parameter Name="m" Type="Object" />
            <asp:Parameter Name="p" Type="String" />
        </InsertParameters>
</asp:ObjectDataSource>

, insert ObjectDataSource. InsertParameters, , .

+3
1

, , google , , DataObjectTypeName ObjectDataSource, InsertParameters. , .

: http://www.velocityreviews.com/forums/t297725-objectdatasource-has-no-values-to-insert-error.html

+4

Source: https://habr.com/ru/post/1731114/


All Articles