I've been searching for help and answers for this for three days now, and it's just over my head...
Here's the scenario... A user logs in, and there are a number of reports that need to be displayed on the page. I find out which reports based on a query in the database. It returns all of the information about the reports (ID, Name, RptPath). I then
need to create each of those reports based on the information that the query returns.
My issue is that I can't figure out how to build the Reportviewers in the codebehind.
Here's my way-too-simple idea of what I need to do:
1. Create a reader to loop through the reports that need to be built
2. For each iteration build a Report
3. Add parameters to the report
4. Display the report to the screen (HtmlTextWriter?)
Can someone please help or at least point me in the right direction?
It's a server report, so the report is already made. I just need to display a reportviewer on the page for each report. I can't figure out how to generate the reportviewer using only the codebehind.
It's a server report, so the report is already made. I just need to display a reportviewer on the page for each report. I can't figure out how to generate the reportviewer using only the codebehind.
Basically like this:
For each line in query
Rpt.ServerReport.ReportPath = "path/to/report"
... Set all the parameters
Rpt.RenderControl(...)
I'm not sure what code to use to do that.
Hope that helps. Thanks for your reply!
I generate ReportViewer 2008 using only the codebehind
on my website. Also I use my own parameters processing.
It is NOT an easy task e.g. implementing multi-values cascading parameters.
You really want to display that many reports in one page ? There are two ways you can do that. One way but too much load on server and might be slow is add report viewer into a repeater and bind that to your user selected query list. And on item databound
event of the repeater, use find control method and assign all your parameters and reort path etc.
Other way is, create one master report with all your reports in it [include as sub reports] and use one report viewer to display that master report. Based on the user selected hide or unhide the sub reports. I would recommend second method.
Raghu
(MCSD.NET, MCAD.NET, MCDBA)
[Don't forget to click on Mark as answer on the post that helped you ]
Marked as answer by rchamberlin on Feb 02, 2009 02:13 PM
if (File.Exists(strReportPath))
{
HtmlTableCell tblCell = new HtmlTableCell();
ReportViewer rptViewer = new ReportViewer(); //creating report viewer for each entity
You really want to display that many reports in one page ? There are two ways you can do that. One way but too much load on server and might be slow is add report viewer into a repeater and bind that to your user selected query list. And on item databound
event of the repeater, use find control method and assign all your parameters and reort path etc.
Thank you for your reply. This is exactly what I was looking for. The reports are currently being displayed on the page and the load is fine. The reports are all VERY small, so everything is working when I just add the reportviewers statically.
I still haven't gotten it working yet, but this is the track I was looking to get on.
rchamberlin
Member
2 Points
10 Posts
Building ReportViewers Dynamically
Jan 28, 2009 01:36 PM|LINK
I've been searching for help and answers for this for three days now, and it's just over my head...
Here's the scenario... A user logs in, and there are a number of reports that need to be displayed on the page. I find out which reports based on a query in the database. It returns all of the information about the reports (ID, Name, RptPath). I then need to create each of those reports based on the information that the query returns.
My issue is that I can't figure out how to build the Reportviewers in the codebehind.
Here's my way-too-simple idea of what I need to do:
1. Create a reader to loop through the reports that need to be built
2. For each iteration build a Report
3. Add parameters to the report
4. Display the report to the screen (HtmlTextWriter?)
Can someone please help or at least point me in the right direction?
Thanks!
rmaiya
Star
11502 Points
1790 Posts
Re: Building ReportViewers Dynamically
Jan 28, 2009 05:48 PM|LINK
are you trying to generate generate report definition (rdl file) at runtime ? or you just need to display a specific report based on user selection ?
(MCSD.NET, MCAD.NET, MCDBA)
[Don't forget to click on Mark as answer on the post that helped you ]
rchamberlin
Member
2 Points
10 Posts
Re: Building ReportViewers Dynamically
Jan 28, 2009 06:05 PM|LINK
It's a server report, so the report is already made. I just need to display a reportviewer on the page for each report. I can't figure out how to generate the reportviewer using only the codebehind.
Basically like this:
For each line in query
Rpt.ServerReport.ReportPath = "path/to/report"
... Set all the parameters
Rpt.RenderControl(...)
I'm not sure what code to use to do that.
Hope that helps. Thanks for your reply!
cioina
Contributor
3728 Points
878 Posts
Re: Building ReportViewers Dynamically
Jan 28, 2009 08:08 PM|LINK
I generate ReportViewer 2008 using only the codebehind on my website. Also I use my own parameters processing.
It is NOT an easy task e.g. implementing multi-values cascading parameters.
rmaiya
Star
11502 Points
1790 Posts
Re: Building ReportViewers Dynamically
Jan 28, 2009 08:18 PM|LINK
You really want to display that many reports in one page ? There are two ways you can do that. One way but too much load on server and might be slow is add report viewer into a repeater and bind that to your user selected query list. And on item databound event of the repeater, use find control method and assign all your parameters and reort path etc.
Other way is, create one master report with all your reports in it [include as sub reports] and use one report viewer to display that master report. Based on the user selected hide or unhide the sub reports. I would recommend second method.
(MCSD.NET, MCAD.NET, MCDBA)
[Don't forget to click on Mark as answer on the post that helped you ]
hilander
Member
130 Points
45 Posts
Re: Building ReportViewers Dynamically
Jan 29, 2009 05:47 AM|LINK
Hi
Try Something like this ::
HtmlTableRow rowMain = new HtmlTableRow();
if (objDataSet.Tables.Rows.Count > 0)
{
if (File.Exists(strReportPath))
{
HtmlTableCell tblCell = new HtmlTableCell();
ReportViewer rptViewer = new ReportViewer(); //creating report viewer for each entity
tblCell.Controls.Add(rptViewer);
rowMain.Cells.Add(tblCell);
tblMain.Rows.Add(rowMain);
tblMain.CellPadding = 3;
tblMain.CellSpacing = 3;
rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
rptViewer.LocalReport.EnableHyperlinks = true;
rptViewer.LocalReport.ReportPath = strReportPath;
rptViewer.LocalReport.ReportEmbeddedResource = (Convert.ToString(strRDLCName) + ".rdlc");
if (objDataSet != null) //alots the datasource for dashboard
{
rptViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", objDataSet.Tables[0]));
}
}
}
rchamberlin
Member
2 Points
10 Posts
Re: Building ReportViewers Dynamically
Feb 02, 2009 02:13 PM|LINK
Thank you for your reply. This is exactly what I was looking for. The reports are currently being displayed on the page and the load is fine. The reports are all VERY small, so everything is working when I just add the reportviewers statically.
I still haven't gotten it working yet, but this is the track I was looking to get on.