I want to generate some reports in my application and I'm using Crystal Reports. The Report itself is correct but I can not load it on my page (.aspx).
Here is my application's Load event code:
protected void Page_Load(object sender, EventArgs e)
{
var doc = new ReportDocument();
doc.Load(MapPath("~/Relatorios/MeuRelatorio.rpt"));
doc.SetDatabaseLogon("my_user","senha123");
this.CrystalReportViewer1.ReportSource = doc;
this.CrystalReportViewer1.PrintMode = PrintMode.Pdf;
this.CrystalReportViewer1.RefreshReport();
}
The code does not display anything on the page, but debugging I was able to see all the results entered in the variable doc . I was able to see your lines, result of login success and etc.
I know that in MVC I can give Return Action with File , and File > I export the report result, eg:
public ActionResult Relatorio()
{
//Restante do código
//Exporta em pdf à variável "stream"
Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
rptH.Refresh();
//Retorna o tipo File
return File(stream, "application/pdf");
}
But in Web Forms I have no idea how I extract this information from the screen.