I am using RadGrid in Web Page and binding it using ObjectDataSource as below:
<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>
Below is the Class file (IPRRequest.cs) code:
[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);
}
Then, I Build using "Debug" and "Release" option, and deploy the .dll
of "Release" folder to the server. It always throw below error:
As I can see all the code is correct in my case. Then why I am getting this error? Please let me know what is wrong in my code or if anything missing. Please reply.
This error was due to missing 3rd parameter string orderBy
(defined in .cs file) but not in ObjectDataSource
. Added this line as below:
<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>
Error resolved.