我在网页中使用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>
下面是类文件(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);
}
然后,我构建使用&#34; Debug&#34;和&#34;发布&#34;选项,并部署.dll &#34;发布&#34;文件夹到服务器。它总是低于错误:
正如我所看到的,所有代码都是正确的。那我为什么会收到这个错误?请让我知道我的代码有什么问题或者是否有任何遗漏。请回复。
答案 0 :(得分:0)
此错误是由于缺少第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>
错误已解决。