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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Report Viewer and user Parameters

Thread ID:

Created:

Updated:

Platform:

Replies:

110142 Jul 21,2013 09:25 PM UTC May 28,2015 01:21 PM UTC WPF 5
loading
Tags: ReportViewer
Charalampos Kouris
Asked On July 21, 2013 09:25 PM UTC

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



Anandakumar S [Syncfusion]
Replied On 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

Charalampos Kouris
Replied On 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


Anandakumar S [Syncfusion]
Replied On 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


saiede
Replied On May 27, 2015 08:33 AM UTC

hi
I  need to download  this sample but Broken link! :(((((

Nithya B [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;