我是telerik報告的新手,我在使用ObjectDataSource的ASP.Net MVC 4中創建了簡單的報告。我創建了一個模型類像下面無法將參數傳遞給使用ObjectDataSource的telerik報告
[DataObject]
public class StockMonitoring
{
[DataObjectMethod(DataObjectMethodType.Select)]
public List<StockDetail> GetExpiredDrugBrand(int SiteID)
{
//returns list by calling stored procedure which takes SiteID
}
}
在控制器我使用這個代碼:
using Telerik.Reporting;
..........
............
TypeReportSource Source = new TypeReportSource();
Source.TypeName = typeof(StockMonitoring_Expired).AssemblyQualifiedName;
Source.Parameters.Add(new Parameter("SiteID", SID));
ViewBag.ReportSource = Source;
,並考慮下面的代碼:
@(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)
)
當我註釋此行
Source.Parameters.Add(new Parameter("SiteID", SID));
and set design我的報告「SiteMonitoring_Expired」在VS 2012中創建的時間值我上面的代碼正常工作,並且斷點擊中模型中的「GetExpiredDrugBrand」方法,但是當我取消註釋上面的行並刪除SiteID的設計時值時,我的代碼給出下面的錯誤:
An error has occurred while processing Table 'table1': An error has occurred while resolving 'ObjectDataSource' data source: Cannot convert to type System.Int32
我無法SITEID參數傳遞給我的「GetExpiredDrugBrand」方法,這反過來又調用的存儲過程以檢索數據。我閱讀telerik報告文檔,但無法找出問題。代碼有什麼問題?
謝謝您提前......