Hello,
I use on asp.net UriReportSource to produce PDF invoice.
The datasource is now set on trdx file, I would like change the method.
I need to pass datasource from code c#, not set on file trdx.
Could you help me ?
Thank you.
public
string
GetInvoice()
{
string
fileName = Path.GetTempPath() + (Guid.NewGuid()).ToString() +
".pdf"
;
UriReportSource uriReportSource = GetInvoiceUriReportSource();
ExportToPDF(GetReport(uriReportSource), fileName);
return
fileName;
}
private
void
ExportToPDF(UriReportSource reportToExport,
string
fileName)
{
ReportProcessor reportProcessor =
new
ReportProcessor();
RenderingResult result = reportProcessor.RenderReport(
"PDF"
, reportToExport,
null
);
using
(FileStream fs =
new
FileStream(fileName, FileMode.Append))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
}
private
UriReportSource GetInvoiceUriReportSource()
{
UriReportSource uriReportSource =
new
Telerik.Reporting.UriReportSource();
if
(HostingEnvironment.ApplicationPhysicalPath !=
null
)
uriReportSource.Uri = HostingEnvironment.ApplicationPhysicalPath + SettingType.TemplateFacture.GetValue();
else
uriReportSource.Uri = Directory.GetCurrentDirectory() + SettingType.TemplateFacture.GetValue();
return
GetReport(uriReportSource);
}
private
UriReportSource GetReport(UriReportSource report,
int
documentRowId = -1)
{
report.Parameters.Add(
new
Telerik.Reporting.Parameter(
"DocumentID"
, DocumentId));
report.Parameters.Add(
new
Telerik.Reporting.Parameter(
"DocumentLigneID"
, documentRowId));
report.Parameters.Add(
new
Telerik.Reporting.Parameter(
"SocieteNom"
, SettingType.SocieteNom.GetValue()));
report.Parameters.Add(
new
Telerik.Reporting.Parameter(
"SocieteAdresse"
, SettingType.SocieteAdresse.GetValue()));
report.Parameters.Add(
new
Telerik.Reporting.Parameter(
"SocieteCPVille"
, SettingType.SocieteCPVille.GetValue()));
report.Parameters.Add(
new
Telerik.Reporting.Parameter(
"SocieteSiret"
, SettingType.SocieteSiret.GetValue()));
report.Parameters.Add(
new
Telerik.Reporting.Parameter(
"SocieteTEL"
, SettingType.SocieteTEL.GetValue()));
return
report;
}
Hello Emmanuel,
Did you able to do this? I too need the same solution. Can you please let me know if you can assign values to SqlDataSourceParameter
Thanks in advance
Hello kishor,
You may link the SqlDataSource Parameters to Report Parameters. Here are some resources that may help: