我有一个启用编辑的 gridview (CustomerDetails)。当我单击编辑按钮并更新 5/6 字段之一(我将所有字段更改为模板字段,然后将编辑模板设置为我不想编辑的字段的标签)时,我收到一个错误:
“ObjectDataSource 'ObjectDataSource1' 找不到具有参数的非泛型方法 'UpdateCustomerAddressZip':CustomerID、CustomerAddressOne、CustomerAddressTwo、CustomerZip、original_CustomerID”
对象数据源代码是
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="InsertCustomer"
OldValuesParameterFormatString="original_{0}" SelectMethod="CustomerDetails" UpdateMethod="UpdateCustomerAddressZip"
TypeName="Enterprise.CustomerEntityLayer">
<InsertParameters>
<asp:Parameter Name="CustomerID" Type="Int32" />
<asp:Parameter Name="CustomerAddressOne" Type="String" />
<asp:Parameter Name="CustomerAddressTwo" Type="String" />
<asp:Parameter Name="CustomerZip" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="CustomerID" Type="Int32" />
<asp:Parameter Name="CustomerAddressOne" Type="String" />
<asp:Parameter Name="CustomerZip" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="Gridview1" DbType="Int32" Name="CustomerID" PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
而我在实体层的方法是:
Public Function UpdateCustomerAddressZip(ByVal CustomerID As Integer, ByVal CustomerAddressOne As String, ByVal CustomerZip As Integer)
Dim dt As New CustomerDataTable
Dim C_row As CustomerRow = dt.NewCustomerRow
C_row.CustomerID = CustomerID
C_row.CustomerAddressOne = CustomerAddressOne
C_row.CustomerZip = CustomerZip
Adapter.UpdateCustAddZip(CustomerID, CustomerAddressOne, CustomerZip)
End Function
随着 SQL 是
UPDATE Customer
SET CustomerAddressOne = @CustomerAddressOne,
CustomerZip = @CustomerZip
WHERE CustomerID=@CustomerID
谁能告诉我哪里出错了?
谢谢