This is a migrated thread and some comments may be shown as answers.

Passing parameters to report from .Net web form

12 Answers 1257 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 07 Dec 2011, 12:40 AM
Is it possible to pass parameters to a Telerik Report (linked to a Telerik:ReportViewer control) from a web page? Either via Javascript or from code behind?

I am able to do this for Silverlight via WCF and Javascript. I am hoping I can do somethign similar for Telerik Reporting.

12 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 07 Dec 2011, 05:00 PM
Hi Greg,

Yes, you can do it like this (not necessarily in Page_Load, could be on any event, you just need to refresh the report after passing the new parameters, so the changes can take effect):

protected void Page_Load(object sender, EventArgs e)
       {
           var myReport = new TelerikChartLab.MyReport();
           ReportViewer1.Report = testReport;
 
           //this is what you need
           myReport.ReportParameters["Parameter1"].Value = "AAAAAAA";
           ReportViewer1.RefreshReport();
       }

Kind regards,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Dhyan
Top achievements
Rank 1
answered on 19 Jun 2012, 03:36 AM
Hi 
I've used the code below still i'm getting a error "
Invalid value of report parameter 'VolID'.". I've defined a report parameter in the report as VolID ( integer) and left the value blank so that any value passed from the webform can be used by this parameter field. 
So if i hard code a value it displays the report it seems its not accepting the parameter passed from the web form. Can you tell me what i'm missing here. 

Telerik.Reporting.InstanceReportSource instanceReportSource =
new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = new MktTermReport.TermSheetReport();
this.ReportViewer1.ReportSource = instanceReportSource;
 
 
ReportViewer1.ReportSource.Parameters.Add("VoldId", 6841808);
 
ReportViewer1.RefreshReport();
0
Elian
Telerik team
answered on 20 Jun 2012, 10:19 AM
Hi Dhyan,

The ReportSource parameters are not the same as Report parameters. In your case the solution is simple: 
var report = new MktTermReport.TermSheetReport();
var instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = report;
this.ReportViewer1.ReportSource = instanceReportSource;
//instead of this: ReportViewer1.ReportSource.Parameters.Add("VoldId", 6841808);
//add this:
report.ReportParameters["VoldId"].Value = ...;
ReportViewer1.RefreshReport();
 
Kind regards,
Elian
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Sean Drun
Top achievements
Rank 1
answered on 29 Oct 2012, 10:02 PM
Hi Elian,
I am evaluating Telerik Reporting and try to convert few of our in house reports.
I run into a problem. The report is a master - detail report.
Detail is Reporting.List inside report detail section.
I am trying to set ReportParameters["MyPara"].Value = myValue in the List.Panel.ItemDataBinding event.
But the assigned parameter is not known to textbox binding script, textBox.Value=Parameters.MyPara.Value.
I am using Web reportviewer.
Is it allowed to set report paramenter in the event handler?
If not, what is the alternatives?

Thanks,
Sean Drun

0
Elian
Telerik team
answered on 01 Nov 2012, 01:41 PM
Hello Sean,

ReportParameters collection holds the parameters of the definition (or the default values).
The parameters on which the processing depends are obtained through the Telerik.Reporting.Processing.Report.Parameters collection. 
For example:
private void panel1_ItemDataBinding(object sender, EventArgs e)
{
    var panel= sender as Telerik.Reporting.Processing.Panel;
    panel.Report.Parameters["ParameterName"].Value =...
}
Why do you need to change the parameter's value run time? If you explain your scenario in more detail, we might be able to give you some advice on how to work it out.

It will be best you you attach a runnable sample report demonstrating your approach.
 
Regards,
Elian
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Sean Drun
Top achievements
Rank 1
answered on 01 Nov 2012, 02:27 PM
Hi Elian,
Thanks for reply.
I found I have to set sender's Report.Parameters["paraName"].Value, not global Report.Parameters
after submit request.
The reason for changing parameter at run time is -
We need some kind of report variable that we can use to set value in Reporting.List's needdatasource.
When textboxes in List are binded, use that value to do some formating.
Report's paramenters seems like a variable to us, unless we overlook other Telerik Reporting features.

Thanks,
Sean Drun

0
Saul
Top achievements
Rank 1
answered on 29 Jan 2014, 07:05 PM
How can i pass the hidden parameters to Telerik Reports?

I develop a Telerik Report with "Telerik report Tool" and it gives me a .trdx file so I integrated that report to my project with Uri; But now i want to pass some hidden parameters to this report 

How can i do this?
0
Stef
Telerik team
answered on 03 Feb 2014, 12:48 PM
Hello Saul,

Please check my post in the How to pass parameter to ReportViewer forum thread on the same question.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Abinash
Top achievements
Rank 1
answered on 19 Jun 2014, 06:56 AM
Hi,
How can we receive and display a string sended from visual studio.
Fro example i sended a string like
myReport.ReportParameters["Parameter1"].Value = "AAAAAAA";
so i want to display "AAAAAAA" in  telerik report header.
is it possible. if yes, please tell me the step?
0
KS
Top achievements
Rank 1
answered on 20 Jun 2014, 03:45 PM
0
Support ATT
Top achievements
Rank 1
answered on 01 Jul 2020, 07:39 AM
[quote]Elian said:Hi Dhyan,

The ReportSource parameters are not the same as Report parameters. In your case the solution is simple: 
var report = new MktTermReport.TermSheetReport();
var instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = report;
this.ReportViewer1.ReportSource = instanceReportSource;
//instead of this: ReportViewer1.ReportSource.Parameters.Add("VoldId", 6841808);
//add this:
report.ReportParameters["VoldId"].Value = ...;
ReportViewer1.RefreshReport();
 
Kind regards,
Elian
the Telerik team
 

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

 

[/quote]

hi Elian

can you please help me? I have same situation and i want to do like this

this.ReportViewer1.ReportSource = instanceReportSource;

but compiler dont like it : SeverityCodeDescriptionProjectFileLineSuppression State
ErrorCS0029Cannot implicitly convert type 'Telerik.Reporting.ReportSource' to 'Telerik.ReportViewer.Html5.WebForms.ReportSource'
i am using  Telerik Reporting R2 2020 Telerik.Reporting.dll File Version 14.1.20.618 , Telerik.ReportViewer.WebForms.dll same version.

 

can you please help me? 

Best Regards

ATT AG

0
Peter
Telerik team
answered on 03 Jul 2020, 03:21 PM

Hi,

The WebForms ReportSource is of a different type. For more information on how to pass parameter value in the Telerik HTML5 Report Viewer see How to Pass Values to Report Parameters help article.

Regards,
Peter
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Greg
Top achievements
Rank 1
Answers by
Elian
Telerik team
Dhyan
Top achievements
Rank 1
Sean Drun
Top achievements
Rank 1
Saul
Top achievements
Rank 1
Stef
Telerik team
Abinash
Top achievements
Rank 1
KS
Top achievements
Rank 1
Support ATT
Top achievements
Rank 1
Peter
Telerik team
Share this question
or