public My_Report()
{
InitializeComponent();
this.DataSource = null;
this.NeedDataSource += new System.EventHandler(this.My_Report_NeedDataSource);
}
private void My_Report_NeedDataSource(object sender, System.EventArgs e)
{
this.sqlConnection1.ConnectionString = ConfigurationManager.ConnectionStrings["MyDataContext"].ConnectionString;
//Transfer the ReportParameter value to the parameter of the select command
this.sqlDataAdapter1.SelectCommand.Parameters["@PersonID"].Value = this.ReportParameters["PersonId"].Value;
this.sqlDataAdapter1.SelectCommand.Parameters["@OperatorID"].Value = this.ReportParameters["OperatorId"].Value;
//Take the Telerik.Reporting.Processing.Report instance and set the adapter as it's DataSource
Telerik.Reporting.Processing.
Report report = (Telerik.Reporting.Processing.Report)sender;
report.DataSource =
this.sqlDataAdapter1;
// set the table datasource as well
table1.DataSource = report.DataSource;
// get the picture paths for the person and the company logo
pbPerson.Value =
this.ReportParameters["PersonPicturePath"].Value;
pbContractor.Value =
this.ReportParameters["ContractorPicturePath"].Value;
pbOperator.Value =
this.ReportParameters["OperatorPicturePath"].Value;
}
}
Also, I am creating the pdf and saving it to the file system, then opening the pdf as content in my page. Here is how I am save the pdf report to the file system:
void SaveReport(Telerik.Reporting.Report report, string fileName)
{
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", report, null);
using (FileStream fs = new FileStream(fileName, FileMode.Create))
{
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
}
Then, my pdf shows as embedded content in my aspx page like this:
<EMBED id="showPDF" runat="server" type="application/pdf" width="750" height="550"></EMBED>
A bit more info:
I am able to run the sproc standalone from inside sql-server management studio with no problems. Also, a pdf report does get created, but it only has header information. The detail section which has the table based on the sproc and a picture box is simply blank.
Anyway, all of this was working in the very recent past and is not working now.
Any ideas on why this is happening would be greatly appreciated!
Mike
We are working on a telerik controls based project in which we have to generate a report and export it to a PDF format.
Everything is working fine and I am getting a pop-up the moment I click on ExportToPdf button. It asks to open, save or cancel. Save is working but if I select Open I am getting the following error.
Adobe Reader could not open 'RadGrid Export[2].pdf' because it is either not a supported file type or because the file has been damaged.
When I googled I found few links which says to download latest dlls’ which also is not working.
Any kind of help is appreciated.
[A]Telerik.Reporting.Report cannot be cast to [B]Telerik.Reporting.Report. Type A originates from 'Telerik.Reporting, Version=2.5.8.519, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' in the context 'LoadNeither' at location 'C:\Documents and Settings\michal.zubek\Local Settings\Application Data\Microsoft\VisualStudio\9.0\ProjectAssemblies\s1-ldctp01\Telerik.Reporting.dll'. Type B originates from 'Telerik.Reporting, Version=2.5.8.519, Culture=neutral, PublicKeyToken=a9d7983dfcc261be' in the context 'LoadFrom' at location 'C:\Projects\VS2008\AshWebPdfClasses\AshWebPdfClasses\bin\Telerik.Reporting.dll'. Do you know how to correct this issue? Thank you very much for your help. |