Here is the code:
private void crosstab1_NeedDataSource(object sender, EventArgs e)
{
using (EntitiesModel dbContext = new EntitiesModel())
{
int dealid = Global.GetInt32(this.ReportParameters["dealID"].Value.ToString());
int version = Global.GetInt32(this.ReportParameters["version"].Value.ToString());
bool amended = Global.GetBool(this.ReportParameters["amended"].Value.ToString());
bool postContract = Global.GetBool(this.ReportParameters["postContract"].Value.ToString());
bool staging = Global.GetBool(this.ReportParameters["staging"].Value.ToString());
bool commOption = Global.GetBool(this.ReportParameters["commOption"].Value.ToString());
IEnumerable<
rsDealsDealerOpt
> d = dbContext.GetDealsDealerOptions(dealid, version, postContract, staging, amended, commOption);
crosstab1.DataSource = d;
}
Thanks,
Richard
7 Answers, 1 is accepted
The correct way of utilizing parameter values in a report event handler is to take them from the Processing.Report.Parameters collection. This is explained more thoroughly in the Using Report Parameters programmatically help article.
Here is the modified NeedDataSource event handler which should work as expected:
private
void
crosstab1_NeedDataSource(
object
sender, EventArgs e)
{
var crosstab = (Telerik.Reporting.Processing.Table)sender;
var parameters = crosstab.Report.Parameters;
using
(EntitiesModel dbContext =
new
EntitiesModel())
{
int
dealid = Global.GetInt32(parameters[
"dealID"
].Value.ToString());
int
version = Global.GetInt32(parameters[
"version"
].Value.ToString());
bool
amended = Global.GetBool(parameters[
"amended"
].Value.ToString());
bool
postContract = Global.GetBool(parameters[
"postContract"
].Value.ToString());
bool
staging = Global.GetBool(parameters[
"staging"
].Value.ToString());
bool
commOption = Global.GetBool(parameters[
"commOption"
].Value.ToString());
IEnumerable<rsDealsDealerOpt> d = dbContext.GetDealsDealerOptions(dealid, version, postContract, staging, amended, commOption);
crosstab.DataSource = d;
}
Peter
Telerik
Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.
Looking closely to the provided code snippet we have noticed that you use DBContext. Generally in Q2 2013 SP1 we have added support for DBContext to the EntityDataSource component. Generally our recommendation is when possible to use the declarative approach provided by the report designer. Thus our suggestion is to try the EntityDataSource component from Q2 2013 SP1.
However if you decide to keep your event handling approach our suggestion is to check the GetDealsDealerOptions method because it is the most probable origin of the error.
Peter
Telerik
Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.
i guess I should say i am using version 2013.1.418.2 of OpenAccess
Another thing you can do is to test with a simple control like grid to check if the data is retrieved correctly or more information bubbles for the error.
SN