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

Passing peporting parameters from WindowsForm Codebehind to Report

2 Answers 90 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Danilo
Top achievements
Rank 1
Danilo asked on 03 May 2013, 01:11 PM
Hello,

I'm working on a Windows Forms Application where I want to load Reports into a Reportviewer after a click on a Button.
This is the Event that gets triggered by pressing on the button in the Code behind of the Windows Form:

private void button1_Click(object sender, EventArgs e)
{
 
    Telerik.Reporting.InstanceReportSource reportSource = new
    Telerik.Reporting.InstanceReportSource();
    reportSource.ReportDocument = new Reportlibrary.Report1();
 
    reportSource.Parameters.Add(new Telerik.Reporting.Parameter("OrderNumber","123456789"));
 
    reportViewer1.ReportSource = reportSource;
    reportViewer1.RefreshReport();
 
}

The problem now is that I have no Idea how I can access / get the parameter I added before Refreshing the Reportviewer.
The Report already has set a Datasource. I don't know if this matters.
This is what I have right now. I've tried everything and I'm just not getting further.

public Report1()
        {
            InitializeComponent();
 
            Position[] all = new Position[]{
 
               new Position("Test", "Test","test"),
 
            };
 
            this.DataSource = all;
 
             MessageBox.Show("Number: " +
             this.Report.ReportParameters["OrderNumber"].Value.ToString());
                 
        }

Is there any way to get this parameter straight after InitializeComponent(); ?
Do I need to add another Event to the report to access it? If yes which on is the best way to do this?

Any help very apreciated.
Thank you

2 Answers, 1 is accepted

Sort by
0
Danilo
Top achievements
Rank 1
answered on 06 May 2013, 08:23 AM
Still no Progress. Anyone any idea?

Thanks
0
Peter
Telerik team
answered on 06 May 2013, 09:02 AM
Hi Danilo,

We have reviewed your code snippet and noticed that you invoke the report constructor prior setting the report parameter value.

Generally the report parameters are designed for use in expressions. Thus in order to advise you appropriately we will appreciate if you elaborate further on your requirement.

Additionally you may find useful the Report Life Cycle help article.

All the best,
Peter
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

Tags
General Discussions
Asked by
Danilo
Top achievements
Rank 1
Answers by
Danilo
Top achievements
Rank 1
Peter
Telerik team
Share this question
or