Hi,
How to pass the parameter value to designer (i.e. C# code to .dplx file) and i used the parameter class where as its works only SP
how to get this?
ManyThanks
How to pass report parameter value from C# to (.dplx) file
Re: How to pass report parameter value from C# to (.dplx) file
Support · Aug 11, 2014Hello,
Yes, you can pass the parameter to the DPLX at run time using DynamicPDF ReportWriter for .NET product. You will need to create ParameterDictionary class object and then add the parameters to and pass this object to Run method of DocumentLayout object. Also you can refer to the documentation on report parameters here
.
Thanks,
ceTe Software Support Team
Re: How to pass report parameter value from C# to (.dplx) file
Forum member · Aug 12, 2014Hi,
Many Thanks for reply
I have tried this approach it's not working
There is no value property for RecordArea or RecordBox controls, only Field property are there
Example Code:
ParameterDictionary parameters = new ParameterDictionary();
parameters.Add("UserID", "1");
parameters.Add("GroupID", "1");
parameters.Add("ReportID", "SummaryPortfolioImplementation");
parameters.Add("By", "Test123");// This parameter value i need to display in report file (i.e. SummaryPortfolioImplementation.aspx.dplx file)
DocumentLayout reportDocument = new DocumentLayout("SummaryPortfolioImplementation.aspx.dplx");
Document document = reportDocument.Run(parameters);
DrawPdfToWeb("SummaryPortfolioImplementation.pdf");
Re: How to pass report parameter value from C# to (.dplx) file
Support · Aug 14, 2014Hello,
Please add the parameters to the DPLX file using the syntax as show below and this will work for you.
Setting the Text property of the RecordArea: #Parameters["UserID"]#
Setting the Field property of the RecordBox : Parameters["UserID"]
Also please note that you can add more than one field value and parameters to the RecordArea and only one field or parameter to the RecordBox.
Thanks,
ceTe Software Support Team
Re: How to pass report parameter value from C# to (.dplx) file
Forum member · Jan 31, 2015What do you set the query field to on this approach? I am getting a connection string valid error each time i try to use the dplx
Re: How to pass report parameter value from C# to (.dplx) file
Support · Feb 2, 2015Hello,
In the query field of the DPLX file, you have to specify an appropriate query that would retrieve the data from the database, in order to fill in the template for generating the PDF. Also specify a valid connection string to the database in the connection string field to avoid the error. Here is the documentation link
on this topic.
Thanks,
ceTe Software support Team.
Re: How to pass report parameter value from C# to (.dplx) file
Forum member · Jul 13, 2015OK, this should be simple. In my .dplx file I have a VERY SIMPLE query :
select * from DeviceData
where SerialNumber = #Parameters["SerialNumber"]#
and CreatedAt >= #Parameters["StartDate"]#
and CreatedAt <= #Parameters["EndDate"]#
and in my C# I have this:
var reportDoc =
new DocumentLayout(
@"C:\Temp\Standard_Report.dplx");
SqlQuery query = (SqlQuery)reportDoc.GetElementById("Query1");
query.ConnectionString = System.Security.SecurityElement.Escape(connectionString);
query = (SqlQuery)reportDoc.GetElementById("Query2");
query.ConnectionString = System.Security.SecurityElement.Escape(connectionString);
var reportParms = new ParameterDictionary();
reportParms.Add("RequestedBy", "Russell de Pina");
reportParms.Add("RequestDate", DateTime.Now.ToString("yyyy-MMM-dd"));
reportParms.Add("SerialNumber", "100000002");
reportParms.Add("StartDate", startDate);
reportParms.Add("EndDate", endDate);
var doc = reportDoc.Run(reportParms);
doc.Draw(@"C:\Temp\reportTest.pdf");
At this point, I'll not touch on the bullsh*t related to getting the connection string to work. But what is really got me ticked is the SQL error saying that I have to declare the scalar variable @SerialNumber, which is definitely defined in the ParameterDictionary for the report.
Why is the parameter value substution not happening?
Not a happy customer
Re: How to pass report parameter value from C# to (.dplx) file
Support · Jul 15, 2015Hello,
After reviewing the dplx file, the exception “Must declare the scalar variable @SerialNumber” is caused by an unwanted or incorrect query used in the dplx file. Removing this query resolved the above said error.
Thanks,
ceTe Software support Team.