vb.net ObjectDataSource 找不到具有参数的非泛型方法:

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17792285/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:20:44  来源:igfitidea点击:

ObjectDataSource could not find a non-generic method that has parameters:

asp.netvb.netobjectdatasourcedataadapter

提问by gbam

I'm trying to use a Gridview to show a datatable from an Object data source. It's giving me the error:

我正在尝试使用 Gridview 来显示来自对象数据源的数据表。它给了我错误:

ObjectDataSource 'odsStores' could not find a non-generic method 'ProcessDelete' that has parameters: ProcessID.

I've read a lot of other answers to this question about matching case, matching format, variables but I think I've done all of those correctly. Here's the aspx page:

我已经阅读了很多关于匹配大小写、匹配格式、变量的问题的其他答案,但我认为我已经正确地完成了所有这些。这是aspx页面:

                <asp:GridView ID="gridStores" runat="server" AllowSorting="False" AutoGenerateColumns="False"
                    CssClass="grid-main" DataSourceID="odsStores" EnableViewState="False" OnDataBound="gridStores_DataBound"
                    OnRowDataBound="gridStores_RowDataBound">
                    <Columns>
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:Image ID="imgModel" runat="server" AlternateText="Click to See Details" CssClass="img-details"
                                    EnableViewState="False" ImageUrl="~/img/detail.gif" />
                            </ItemTemplate>
                            <ItemStyle CssClass="grid-main-detail" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="ProcessID" HeaderText="ProcessID" />
                        <asp:BoundField DataField="ProcessName" HeaderText="Process Name" ReadOnly="False" />
                        <asp:BoundField DataField="ProcessDescription" HeaderText="Process Description" ReadOnly="False" />
                        <asp:BoundField DataField="UpdateUserID" HeaderText="Last Updated By" ReadOnly="True" />
                        <asp:BoundField DataField="UpdateTimestamp" HeaderText="Last Updated" ReadOnly="True" />
                        <asp:CommandField ShowEditButton="True" />
                        <asp:CommandField ShowDeleteButton="True" />
                    </Columns>
                </asp:GridView>

Here's the code behind, all I have is a break point and it never hits it.

这是背后的代码,我所拥有的只是一个断点,它永远不会命中它。

<DataObjectMethod(DataObjectMethodType.Delete)> _
Private Sub ProcessDelete(ByVal ProcessID As String)
    Dim x As Integer = 0
    x = x + 1
End Sub

Here's the object datasource:

这是对象数据源:

<asp:ObjectDataSource ID="odsStores" runat="server" EnableViewState="False" OldValuesParameterFormatString="original_{0}"
                    SelectCountMethod="GetRowCount" SelectMethod="GetData" TypeName="DataWarehouseUserInterface.ProcessBSL"
                    UpdateMethod="ProcessUpdate" DeleteMethod="ProcessDelete" >
                    <UpdateParameters>
                        <asp:FormParameter Name="ProcessName" Type="String" FormField="ProcessName" />
                        <asp:FormParameter Name="ProcessDescription" Type="String" FormField="ProcessDescription" />
                    </UpdateParameters>
                    <DeleteParameters>
                        <asp:FormParameter Name="ProcessID" Type="String"/>
                    </DeleteParameters>
                </asp:ObjectDataSource>

回答by gbam

My Object data source was looking in my ProcessBSL for a method called ProcessDelete with the corresponding signature. I had written my methods in the code behind ProcessBSL file.

我的对象数据源正在我的 ProcessBSL 中寻找一个名为 ProcessDelete 的方法,并带有相应的签名。我已经在 ProcessBSL 文件后面的代码中编写了我的方法。

This was the line of code that effected it:

这是影响它的代码行:

TypeName="DataWarehouseUserInterface.ProcessBSL"

Summary: If it's throwing this error for you, ensure your method signature is correct. Ensure that the BSL layer is correct. Make sure you have _ - that also stopped mine from working. Hope this helps someone else.

摘要:如果它为您抛出此错误,请确保您的方法签名正确。确保 BSL 层正确。确保你有 _ - 这也阻止了我的工作。希望这对其他人有帮助。

Cheers.

干杯。

回答by Brian Mains

Try making the method public to see if that works.

尝试将方法公开以查看是否有效。