I am new to telerik reporting and I created simple report in ASP.Net MVC 4 which use ObjectDataSource. I created one model class like below
[DataObject]
public class StockMonitoring
{
[DataObjectMethod(DataObjectMethodType.Select)]
public List<StockDetail> GetExpiredDrugBrand(int SiteID)
{
//returns list by calling stored procedure which takes SiteID
}
}
In controller I am using this code:
using Telerik.Reporting;
..........
............
TypeReportSource Source = new TypeReportSource();
Source.TypeName = typeof(StockMonitoring_Expired).AssemblyQualifiedName;
Source.Parameters.Add(new Parameter("SiteID", SID));
ViewBag.ReportSource = Source;
and In view following code:
@(Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl("/api/reports/")
.TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate-8.1.14.804.html")
.ReportSource((ReportSource) ViewBag.ReportSource)
.ViewMode(ViewModes.INTERACTIVE)
.ScaleMode(ScaleModes.SPECIFIC)
.Scale(1.0)
.PersistSession(false)
)
When I comment this line
Source.Parameters.Add(new Parameter("SiteID", SID));
and set design time value for SiteID in my report "StockMonitoring_Expired" which is created in VS 2012 my above code works properly and break point hit "GetExpiredDrugBrand" method in model but when I uncomment above line and remove design time value for SiteID my code give below error:
An error has occurred while processing Table 'table1': An error has occurred while resolving 'ObjectDataSource' data source: Cannot convert to type System.Int32
I am not able to pass SiteID parameter to my "GetExpiredDrugBrand" method which in turn called stored procedure to retrive data. I read telerik reporting documentation but not able to figure out problem. What's wrong in code?
Thank you in advance......
I found solution of it. While designing report I forgot to add parameter to use. I follow this link for adding parameter http://www.telerik.com/help/reporting/designing-reports-parameters-adding-parameters.html and my problem solved.