I'm having a .NET 4.5 webforms project, with reports using Crystal Reports version 13.0.2000 . Reports do not export, do not explode exceptions , nothing, simply the screen does a refresh postback and nothing happens.
I'm having a .NET 4.5 webforms project, with reports using Crystal Reports version 13.0.2000 . Reports do not export, do not explode exceptions , nothing, simply the screen does a refresh postback and nothing happens.
Resolved, the resolution below follows.
<cr:CrystalReportViewer
ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
OnDataBinding="CrystalReportViewer1_DataBinding" ToolPanelView="None"
HasCrystalLogo="False" HasDrilldownTabs="False"
HasDrillUpButton="False" HasPrintButton="False" HasSearchButton="False"
HasToggleGroupTreeButton="false" HasZoomFactorList="False"
/>
And in the aspx.cs file:
protected void CrystalReportViewer1_DataBinding(object sender, EventArgs e)
{
if (ValidaParametros() && IsPostBack)
CarregaRelatorio();
}
protected void btnBusca_Click(object sender, EventArgs e)
{
CrystalReportViewer1.DataBind();
}
private void CarregaRelatorio()
{
DataSet ds = new DataSet();
try
{
ds = BuscaDadosRelatorio();
if (ds.Tables[0].Rows.Count == 0)
ValidationError.Display(btnBusca, "Não há registros para o critério de busca informado.", ValidationType.Exclamation);
ReportDocument report = new ReportDocument();
switch (ddlExibicao.SelectedValue)
{
case "1":
report.FileName = "RelLancamentoEstorno.rpt";
break;
case "2":
report.FileName = "RelLancamentoInadimplente.rpt";
break;
default:
report.FileName = "RelLancamento.rpt";
break;
}
string reportLoadPath = BuscaParametro();
report.Load(Path.Combine(reportLoadPath, Path.GetFileName(report.FileName)));
report.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = report;
}
catch
{
ValidationError.Display(btnBusca, "Falha ao carregar os dados do relatório.", ValidationType.Sucess);
}
}
What happened was as follows, the "LoadReport" method was initially called in the click event of the fetch button, but it did not work. Then I created the "OnDataBinding" event in the Crystal component and in the click event of the command button to execute the "CrystalReportViewer1.DataBind" event which in turn triggers the "OnDataBinding" event, which calls the "LoadReport" method. With the flow exactly like this (I tried many other things, using the life cycle of the page in several ways) I was able to make the thousands of bugs automatically resolved, pagination, export, printing, js errors, anyway, that was the solution that I found hope it helps.