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

Sending parameters to ReportWriter

Hello!

I would like to design a RDL report and fill it with the data that I always select.

To be more precise, is it possible to send parameters or the data itself to ReportWriter (I would like to avoid using RDLC format for now), so that I can pass that parameters to queries in datasets and if so, how?

I would be glad to receive any thoughts on how to achieve this functionality.

Regards, 

Karmen Gostiša

7 Replies

VS Vinoth Srinivasan Syncfusion Team November 21, 2016 07:23 AM

Hi Karmen, 
 
Thanks for contacting Syncfusion support. 
 
You can use ReportWriter’s  “SetParameters” API to specify values to the ReportParameters used in the report at code behind. Please refer to our Knowledge Base for more details on this. 
 
We have also prepared a sample with RDL report for your reference, it can be downloaded from the following location. 
 
Regards, 
Vinoth S. 



KA Karmen November 21, 2016 03:26 PM

Hi!

Thank you for your helpful answer. The solution does exactly what I need. But just for the side note - there is a bug in your sample. The line reportWriter.Save(fileName, format); and lines concerning MessageBox should be below IList parameters initialization and reportWriter.SetParameters(parameters) otherwise the parameter values do not have any impact.

Regards,

Karmen Gostiša


VS Vinoth Srinivasan Syncfusion Team November 22, 2016 05:21 AM

Hi Karmen, 

Sorry for the inconvenience. 

Yes, you have to set the parameter values before the Save() method in report writer to update the default parameter values. Please let us know if you require further assistance on this. 

Regards, 
Vinoth S. 



AS abelardo silvas cortez replied to Vinoth Srinivasan August 31, 2018 02:23 AM

Hi Karmen, 

Sorry for the inconvenience. 

Yes, you have to set the parameter values before the Save() method in report writer to update the default parameter values. Please let us know if you require further assistance on this. 

Regards, 
Vinoth S. 


Hello
I have a problem with a reference, it flags this error "can not convert from 'System.Collections.Generic.IList <Syncfusion.JavaScript.Models.ReportViewer.ReportParameter>' to 'System.Collections.Generic.IEnumerable <Syncfusion.Reports .EJ.ReportParameter> '"
I hope someone can help me please....


MM Mageshyadav M Syncfusion Team August 31, 2018 08:18 AM

Hi Abelardo, 
 
Can you confirm whether the below sample runs fine on your side, 
 
 
In the above sample, we have passed the IList to IEnumerable collection only but we didn’t get any conversion error. Please find the snippet used, 
 
                IList<ReportParameter> parameters = new List<ReportParameter>(); 
                foreach (var parameter in reportWriter.GetParameters()) 
                { 
                    ReportParameter param = new ReportParameter(); 
 
                    param.Name = parameter.Name; 
 
                    param.Values.Add("Ottawa"); 
 
                    parameters.Add(param); 
 
                } 
 
                reportWriter.SetParameters(parameters); 
 
Otherwise typecast similar to below snippet 
 
reportWriter.SetParameters(parameters as IEnumerable<ReportParameter>); 
 
Regards, 
Mageshyadav.M 



AS abelardo silvas cortez replied to Mageshyadav M August 31, 2018 10:24 AM

Hi Abelardo, 
 
Can you confirm whether the below sample runs fine on your side, 
 
 
In the above sample, we have passed the IList to IEnumerable collection only but we didn’t get any conversion error. Please find the snippet used, 
 
                IList<ReportParameter> parameters = new List<ReportParameter>(); 
                foreach (var parameter in reportWriter.GetParameters()) 
                { 
                    ReportParameter param = new ReportParameter(); 
 
                    param.Name = parameter.Name; 
 
                    param.Values.Add("Ottawa"); 
 
                    parameters.Add(param); 
 
                } 
 
                reportWriter.SetParameters(parameters); 
 
Otherwise typecast similar to below snippet 
 
reportWriter.SetParameters(parameters as IEnumerable<ReportParameter>); 
 
Regards, 
Mageshyadav.M 


thanks for the reply!
I think the problem is in the type of data that does not match
Syncfusion.JavaScript.Models.ReportViewer.ReportParameter
with Syncfusion.Reports .EJ.ReportParameter
cree que sea un using? 


MM Mageshyadav M Syncfusion Team September 3, 2018 01:20 AM

Hi Abelardo, 
  
Thanks for your update.  
  
Sorry for suggesting sample in WPF based on platform chosen in forum. Yes, you need to pass Syncfusion.Reports.EJ.ReportParameter only to report writer setParameter method. 
  
Hope, the issue has been resolved on your side based on proper namespace reference.  
  
Regards, 
Mageshyadav.M 


Loader.
Live Chat Icon For mobile
Up arrow icon