Greetings,
I seem to be having a problem when using the web based Report Viewer when I set the report parameters at run time.
Here's a summary of the problem:
I have a report that is generating a data source in the NeedDataSource event.
The data source is being generated using data from the ReportParameters collection.
I have an aspx page that has a viewer control that is not bound to a report at design time.
My report page has a series of input controls that can be used to change the report parameters.
After the user enters his report parameters and clicks the submit button, the code behind creates a new report object, assigns the parameters and then assigns the report to the viewer control.
This works fine the first time the user generates the report. If the user changes his parameters and regenerates the report, the report is always generated using the first set of parameters.
Here is some of the sample code:
GenerateReport(p1,p2) is called when the user clicks a "submit" button. I've simplified the parameters for ease of reading.
ToplineMaster and VerbatimMaster are the report objects. Based on the input from the user, we determine which report to show (but this only happens on the first load of the page, the user does not change report types on the fly)
Both report types use a similar NeedDataSource method. I changed it a bit to keep things simple, but basically I'm generating report line items based on data generated from my business logic layer and then binding those line items to the report. The report works fine when I run it the first time.
I did some searching around today, but couldn't find the magic google/forum search query to find an explanation which leads me to believe that I'm doing something wrong.
Can anyone offer a hand?
Thanks!
I seem to be having a problem when using the web based Report Viewer when I set the report parameters at run time.
Here's a summary of the problem:
I have a report that is generating a data source in the NeedDataSource event.
The data source is being generated using data from the ReportParameters collection.
I have an aspx page that has a viewer control that is not bound to a report at design time.
My report page has a series of input controls that can be used to change the report parameters.
After the user enters his report parameters and clicks the submit button, the code behind creates a new report object, assigns the parameters and then assigns the report to the viewer control.
This works fine the first time the user generates the report. If the user changes his parameters and regenerates the report, the report is always generated using the first set of parameters.
Here is some of the sample code:
GenerateReport(p1,p2) is called when the user clicks a "submit" button. I've simplified the parameters for ease of reading.
ToplineMaster and VerbatimMaster are the report objects. Based on the input from the user, we determine which report to show (but this only happens on the first load of the page, the user does not change report types on the fly)
private void GenerateReport(List<int> p1, List<int> p2) |
{ |
if(Mode == 1) |
{ |
ToplineMaster report = new ToplineMaster(); |
report.ReportParameters["p1"].Value = p1; |
report.ReportParameters["p2"].Value = p2; |
rv_Rpt_Viewer.Report = report; |
} |
else if (Mode == 2) |
{ |
VerbatimMaster report = new VerbatimMaster(); |
report.ReportParameters["p1"].Value = p1; |
report.ReportParameters["p2"].Value = p2; |
rv_Rpt_Viewer.Report = report; |
} |
} |
Both report types use a similar NeedDataSource method. I changed it a bit to keep things simple, but basically I'm generating report line items based on data generated from my business logic layer and then binding those line items to the report. The report works fine when I run it the first time.
private void ToplineMaster_NeedDataSource(object sender, EventArgs e) |
{ |
// given the question ids, load the questions from the database |
// and bind the list to the report |
List<int> p1 = new List<int>(); |
p1 = (List<int>)(sender as Telerik.Reporting.Processing.Report).Parameters["p1"]; |
List<int> p2 = new List<int>(); |
p2 = (List<int>)(sender as Telerik.Reporting.Processing.Report).Parameters["p2"]; |
List<BusinessDataObject> lineItems = new List<BusinessDataObject>(); |
foreach (int id in p1) |
{ |
// generate data from business objects/database |
lineItems.Add(Data); |
} |
(sender as Telerik.Reporting.Processing.Report).DataSource = lineItems; |
} |
I did some searching around today, but couldn't find the magic google/forum search query to find an explanation which leads me to believe that I'm doing something wrong.
Can anyone offer a hand?
Thanks!