【问题标题】:ObjectDataSource 'odsMonthlyStatusReport' could not find a non-generic method 'GetMonthlyReportData' that has parameters: month, yearObjectDataSource 'odsMonthlyStatusReport' 找不到具有参数的非泛型方法 'GetMonthlyReportData':月、年
【发布时间】:2015-08-19 03:04:42
【问题描述】:

我在网页中使用 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);
        }

然后,我使用“调试”和“发布”选项构建,并部署 .dll 的“发布”文件夹到服务器。它总是抛出以下错误:

我可以看到所有代码在我的情况下都是正确的。那为什么我会收到这个错误?请让我知道我的代码有什么问题或者有什么遗漏。请回复。

【问题讨论】:

    标签: c# asp.net radgrid objectdatasource


    【解决方案1】:

    此错误是由于缺少第三个参数 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>
    

    错误已解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多