Friday, March 30, 2012

ReportViewer control in webform

I know this should be simple, but I can't find it. I'm trying to use
the reportviewer control
in a webform.
I'm following along with the example at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSAMPLES/htm/rss_sampleapps_v1_7944.asp
which is fine as far as it goes, but my report has parameters.
Elsewhere I've been able to render a report using
ParameterValue[] parameters = new ParameterValue[2];
...
MyReport.SetExecutionParameters(parameters, "en-us");
But in my current problem I've tried to use something similar, and also
ReportParameters[] = new ReportParameters[2];
...
ReportViewer1.ServerReport.SetParameters(ReportParameters);
without success.
If somebody has a working example I would appreciate it.
TIA,
JimWhat exactly is not working in your case? What happens if you don't set
parameters at all?
/// <summary>
/// Requests a remote report that runs under the context of the Report
Server
/// </summary>
private void RunRemote()
{
reportViewer.ProcessingMode =Microsoft.Reporting.WebForms.ProcessingMode.Remote;
// Get the Report Server endpoint from the config file
reportViewer.ServerReport.ReportServerUrl = new
Uri(ConfigurationManager.AppSettings["ReportServerEndPoint"]);
reportViewer.ServerReport.ReportPath = <full report path>";
SetParameters();
}
/// <summary>
/// Set the report prameter for the Customer Orders report
/// </summary>
private void SetParameters()
{
ReportParameter[] parameters = new ReportParameter[2];
parameters[0] = new ReportParameter("Date", "1/1/2003");
parameters[1] = new ReportParameter("CustomerID", new string[] {
"14335", "15094" }); //multi-value parameter
reportViewer.ServerReport.SetParameters(parameters);
}
--
HTH,
---
Teo Lachev, MVP, MCSD, MCT
"Microsoft Reporting Services in Action"
"Applied Microsoft Analysis Services 2005"
Home page and blog: http://www.prologika.com/
---
<jhcorey@.yahoo.com> wrote in message
news:1136320002.295595.215520@.f14g2000cwb.googlegroups.com...
>I know this should be simple, but I can't find it. I'm trying to use
> the reportviewer control
> in a webform.
> I'm following along with the example at
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/RSAMPLES/htm/rss_sampleapps_v1_7944.asp
> which is fine as far as it goes, but my report has parameters.
> Elsewhere I've been able to render a report using
> ParameterValue[] parameters = new ParameterValue[2];
> ...
> MyReport.SetExecutionParameters(parameters, "en-us");
> But in my current problem I've tried to use something similar, and also
>
> ReportParameters[] = new ReportParameters[2];
> ...
> ReportViewer1.ServerReport.SetParameters(ReportParameters);
> without success.
> If somebody has a working example I would appreciate it.
> TIA,
> Jim
>|||I didn't note that I'm working in VS2005. I notice the link I noted
above is for VS2003.
Anyway, my problem may be finding the correct namespace for
ReportParameters.
I've included ReportExecution2005 as a web reference, and I can do
this:
ReportParameter[] parameters = new ReportParameter[2];
But when I do this:
parameters[0] = new ReportParameter("Date", "1/1/2003");
I get 'No overload method for Report Parameter takes 2 arguments'
If I use
parameters[0] = new ReportParameter();
then I can't find a property to set the value.|||Ok, I'm moving forward. I'm using the Microsoft.Reporting.Webforms
namespace.
Which has a different ReportParameter.

No comments:

Post a Comment