ObjectDataSource 'odsMonthlyStatusReport' 找不到具有参数的非泛型方法 'GetMonthlyReportData':月、年

ObjectDataSource 'odsMonthlyStatusReport' could not find a non-generic method 'GetMonthlyReportData' that has parameters: month, year

我在网页中使用 RadGrid 并使用 ObjectDataSource 绑定它,如下所示:

   <asp:ObjectDataSource ID="odsMonthlyStatusReport" runat="server" SelectMethod="GetMonthlyReport_Test" TypeName="atQuest.Projects.Sunway.IPRRequest">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="ddlMonth" Name="month" PropertyName="SelectedValue"
                                Type="String" ConvertEmptyStringToNull="true"  />
                            <asp:ControlParameter ControlID="ddlYear" Name="year" PropertyName="SelectedValue"
                                Type="String" ConvertEmptyStringToNull="true"  />
                        </SelectParameters>
                    </asp:ObjectDataSource>

                    <telerik:RadGrid ID="GridReport" runat="server" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" ShowGroupPanel="True"
                    CellSpacing="0" GridLines="None" Width="100%" Skin="Outlook" DataSourceID="odsMonthlyStatusReport" OnItemDataBound="GridReport_ItemDataBound">

                            <ClientSettings AllowDragToGroup="True" />
                            <GroupingSettings CaseSensitive="false"></GroupingSettings>
                            <MasterTableView AllowFilteringByColumn="true" AllowMultiColumnSorting="false" AutoGenerateColumns="false"
                                    CommandItemDisplay="Top" DataKeyNames="RequestID" EnableGroupsExpandAll="true"
                                    GroupLoadMode="Client" PageSize="50">

                            <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToExcelButton="true" />
                            <SortExpressions>
                                <telerik:GridSortExpression FieldName="RequisitionNo" SortOrder="Descending" />
                            </SortExpressions>
                            <PagerStyle AlwaysVisible="True" PageSizeControlType="RadComboBox" Position="Bottom" PageSizes="50,100,150,200" />

                                        <Columns>
                                            //all GridBound columnc
                                        </Columns>
                                    </MasterTableView>
                                    <ExportSettings SuppressColumnDataFormatStrings="True" IgnorePaging="True" ExportOnlyData="True" Excel-Format="ExcelML" OpenInNewWindow="True" FileName="eAPDocHistory" Excel-FileExtension="xls">
                                    </ExportSettings>
                                </telerik:RadGrid>

下面是 Class 文件 (IPRRequest.cs) 代码:

[DataObjectMethod(DataObjectMethodType.Select, true)]
        public static DataTable GetMonthlyReport_Test(string Month, string Year, string orderBy)
        {
            Data data = new Data();
            Dictionary<string, object> input = new Dictionary<string, object>()
            {
                {"@Month", Month},
                {"@Year", Year},
            };
            return data.ExecuteQuery(CommandType.StoredProcedure, "[Invoice].[usp_tbl_Request_Select_MonthlyStatusReport]", input);
        }

然后,我 Build 使用 "Debug" 和 "Release" 选项,并部署 .dll "Release" 个文件夹到服务器。它总是抛出以下错误:

据我所知,所有代码在我的案例中都是正确的。那为什么我会收到这个错误?请让我知道我的代码有什么问题,或者是否有任何遗漏。请回复。

此错误是由于缺少第 3 个参数 string orderBy(在 .cs 文件中定义)而不是 ObjectDataSource。添加此行如下:

<asp:ObjectDataSource ID="odsMonthlyStatusReport" runat="server" SelectMethod="GetReportData" TypeName="atQuest.Projects.Sunway.IPRRequest">
     <SelectParameters>
          <asp:ControlParameter ControlID="ddlMonth" Name="month" PropertyName="SelectedValue" Type="String" ConvertEmptyStringToNull="true"  />
          <asp:ControlParameter ControlID="ddlYear" Name="year" PropertyName="SelectedValue" Type="String" ConvertEmptyStringToNull="true"  />
          <asp:Parameter DefaultValue="" Name="orderBy" Type="String" />
     </SelectParameters>
</asp:ObjectDataSource>

错误已解决。