Hi, recently started using the free trial of Telerik Reporting in my MVC project. So what I do is, on the client side, when a button is pressed, it sends down an ID to the controller which calls GetReport to get data matching the ID, and then return a report back to the client. However, I keep getting this error <ExceptionMessage>Invalid value of report parameter 'id'.</ExceptionMessage>.
What am I doing wrong? I think I'm doing this correctly going by the resources: http://www.telerik.com/help/reporting/entitydatasource-connecting-to-entity-data-model.html
NB: int
_stuffId
is never null, it does have a value when I debugged the app.
// ReportRepo.cs
public
Report GetReportData(
int
_id)
{
return
m_context.Stuff.SingleOrDefault(c => c.StuffId == _id);
}
// controller
public
HttpResponseMessage GetReport(
int
_stuffId)
{
try
{
EntityDataSource entityDataSource =
new
EntityDataSource();
entityDataSource.ObjectContext =
typeof
(ReportRepo);
entityDataSource.ObjectContextMember =
"GetReportData
"
;
entityDataSource.Parameters.Add(
"_id"
,
typeof
(
int
), _stuffId
);
Report1 report1 =
new
Report1();
report1.DataSource = entityDataSource;
ReportProcessor reportProcessor =
new
ReportProcessor();
InstanceReportSource instanceReportSource =
new
InstanceReportSource();
instanceReportSource.ReportDocument = report1;
RenderingResult result = reportProcessor.RenderReport(
"PDF"
, instanceReportSource,
null
);
HttpResponseMessage response =
new
HttpResponseMessage(HttpStatusCode.OK);
var stream =
new
MemoryStream(result.DocumentBytes);
response.Content =
new
StreamContent(stream);
response.Content.Headers.ContentType =
new
MediaTypeHeaderValue(
"application/octet-stream"
);
response.Content.Headers.ContentDisposition =
new
System.Net.Http.Headers.ContentDispositionHeaderValue(
"attachment"
);
response.Content.Headers.ContentDisposition.FileName = result.DocumentName +
"."
+ result.Extension;
return
response;
}
}