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

Passing Parameters

6 Answers 339 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Maher
Top achievements
Rank 1
Maher asked on 06 Mar 2009, 01:02 PM

I am working on an ASPX page where the user enters some information. When the user click the save button I want to save the entered data then call Telerik’s report passing to it the record_id of the new saved data. I cannot find any information on how to pass parameter to a report. Could someone help me on this issue?

 

Thanks

Maher

6 Answers, 1 is accepted

Sort by
0
Maher
Top achievements
Rank 1
answered on 06 Mar 2009, 04:49 PM
Here what I AM doing

in the ASPX page I have the following code in the onclick button event witch shows the report in reportviewer

 protected void Button1_Click(object sender, EventArgs e)
        {
            DocumentFax.Report1 report = new DocumentFax.Report1();           
            report.ReportParameters.Add("id", Telerik.Reporting.ReportParameterType.String, "1");
            ReportViewer1.Report = report;
        }
The DLL for report is called DocumentFax.DLL. the code I have in the Report1.cs is

public Report1()
        {
            /// <summary>
            /// Required for telerik Reporting designer support
            /// </summary>
            InitializeComponent();
            string strID = this.ReportParameters["id"].Value.ToString();
            more code here
        }

when I click on the button to view the report I get the error shown below

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 19:             /// </summary>
Line 20:             InitializeComponent();
Line 21:             string strID = this.ReportParameters["id"].Value.ToString();

Could someone explain to me how to initialize the parameter so I do not get this error?

Thanks
Maher


0
Steve
Telerik team
answered on 09 Mar 2009, 09:38 AM
Hi Maher,

You should have an existing report parameter in your report, which you can access through your aspx page and pass a value to in the following manner:

this.ReportViewer1.Report.ReportParameters["MyParam"].Value = <your_value>;

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
K N
Top achievements
Rank 1
answered on 10 Jun 2010, 07:58 PM
I used the following code:
reportViewer1.Report.ReportParameters["StudentID"].Value = ID;

but got this error:
Error   1   Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<Telerik.Reporting.ReportParameter>'




0
Steve
Telerik team
answered on 15 Jun 2010, 12:36 PM
Hi K N,

It depends on what Telerik Reporting version you're using. From Q1 2009 we've made some changes to the ReportViewer.Report property (more info in ReportViewer.Report property is now of type Telerik.Reporting.IReportDocument). You can try the following code instead:

Telerik.Reporting.Report report = (Telerik.Reporting.Report)this.ReportViewer1.Report;
report.ReportParameters["StudentID"].Value = ID;

or directly instantiate the report like so:

MyReport myReport = new MyReport();  
myReport.ReportParameters["StudentID"].Value = ID;
 
this.ReportViewer1.Report = myReport;

Kind regards,
Steve
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Divya
Top achievements
Rank 1
answered on 15 Apr 2014, 10:45 AM
I am working on an ASPX page where the user select some information.
When the user click the submit button I want to show the entered data related information then
call Telerik’s report. I cannot find any information on how to pass parameter to a
report.report header is visible but datafield not showing
 Could someone help me on this issue?
0
Stef
Telerik team
answered on 16 Apr 2014, 05:39 PM
Hi Divya,

This is  a quote from my post in your support ticket #806737  on the same question:

"This can be achieved through the Report Source object that wraps the report. The ReportSource.Parameters collection (key-value pairs) is mapped to the underlying Report.ReportParameters collection by key. Using this approach you can pass also Session variable, as long as they are from the supported by the report parameters types: String, Integer, Float, Datetime, Boolean. You can also reassign the ReportViewer.ReportSource to other Report Source object."


In the ticket you can find more links to our documentation and a demo project. If you need any further help, please use our support ticketing system and address your issue in a single thread to avoid splitting information. The thread can be found after logging into your account and checking Your Support tickets.

Thank you for your understanding.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Maher
Top achievements
Rank 1
Answers by
Maher
Top achievements
Rank 1
Steve
Telerik team
K N
Top achievements
Rank 1
Divya
Top achievements
Rank 1
Stef
Telerik team
Share this question
or