We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Starting in 2019, the Reporting control is no longer included in Essential Studio. If you're experiencing issues with the Syncfusion Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion and appreciate your understanding.

Report Viewer and user Parameters

Hi there,

I am using in a WPF App following for printing:

--------------------------------------------------------------------------------------
(using  Microsoft.Reporting.WinForms;)

Form form = new Form();
ReportViewer reportViewer = new ReportViewer();

reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportPath = @"D:\StudentsOverview.rdlc";
reportViewer.LocalReport.DataSources.Add(
    new ReportDataSource("students", StudentRepository.Students));
           
reportViewer.LocalReport.SetParameters(new ReportParameter("ReportName", "My Report"));
           
reportViewer.Dock = DockStyle.Fill;
form.Controls.Add(reportViewer);          
reportViewer.RefreshReport();

form.Show();
----------------------------------------------------------------------------------------------

This works fine but I like to replace this with the Syncfusion ReportViewer (latest version). Unfortunately I can't get it work and cannot find where to set the parameters( for example like: reportViewer.LocalReport.SetParameters(new ReportParameter("ReportName", "My Report"));)

So far I have:

----------------------------------------------------------------------------------------------
(using Syncfusion.Windows.Reports.Viewer;)

ReportPreview printDialog = new ReportPreview();
ReportViewer reportViewer1 = new ReportViewer();

reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.ReportPath = @"D:\StudentsOverview.rdlc";
           
reportViewer1.DataSources.Add(new ReportDataSource("students", StudentRepository.Students));
           
// ??? Not able to find a way to set parameters

printDialog.mainGrid.Children.Add(reportViewer1);

//This doesn't help no matter if I use it or not
printDialog.Loaded += (sender, arg) =>
{
    reportViewer1.RefreshReport();
};

printDialog.Show();

-------------------------------------------------------------------------------------------------

This opens a window but nothing happens.

Can you help me with that?
Charalampos



4 Replies

AS Anandakumar S Syncfusion Team July 22, 2013 12:38 PM UTC

Hi Charalampos,

 

Thanks for using Syncfusion Products.

You can set parameter by using following code.

 

List<ReportParameter> parameters = new List<ReportParameter>();

ReportParameter param = new ReportParameter();

param.Labels.Add("LableName");

param.Values.Add("Values");

param.Name = "ParameterName";

parameters.Add(param);

reportViewerControl.SetParameters(parameters);

 

 

We have prepared a sample based on this and you can find the sample in attachment.

 

Please let us know if you have any queries.

 

Thanks,

Anandakumar S



ReportViewerTest_ee89739f.zip


CK Charalampos Kouris July 23, 2013 09:35 PM UTC

Hi Anandakumar,

thanks for fast reply, that looks really good. Unfortunately I have some problems with the designer and cannot test it directly but I will update as soon as possible.

Anyway, is it possible to use a dataset/datasource from code behind (for example a list of business objects) as a datasource for the report? Maybe someone can give a sort answer on that.

Thanks a lot!
Charalampos



AS Anandakumar S Syncfusion Team July 24, 2013 12:38 PM UTC

Hi Charalampos,

 

Thanks for your update.

You can add datasource/dataset to the ReportDesigner from a local report in code behind using following code.

 

ReportDesignerControl.AddDataSource("ReportPath""DataSourceName");

ReportDesignerControl.AddDataSet("ReportPath""DataSetName");

 

 

Please let us know if you have any queries.

 

Thanks,

Anandakumar S



NB Nithya B Syncfusion Team May 28, 2015 01:21 PM UTC

Hi Saiede,

Sorry about the inconvenience caused.

We have uploaded the sample for “Setting parameter values in code behind” and it can be downloaded from the following location.
http://www.syncfusion.com/downloads/support/forum/110142/ze/Parameter_Sample2068042735

And also kindly refer the below online UG link for more details on this.
http://help.syncfusion.com/ug/wpf/Documents/providethereportparametersincodebehind.htm

Please let us know, if you need any further assistance on this.

Regards,
Nithya B

Loader.
Live Chat Icon For mobile
Up arrow icon