Asked by:
How to refresh a crystal report !!

Question
-
User-746270871 posted
I deployed my website in IIS 7.5, when i click on the button to open the page that contain the report, i get a blank page for the first time,but when i refresh the page it's ok. it's happened just for the first load. how can i fix this problem ?
please help me.Thanks in advance.Sunday, December 28, 2014 10:51 AM
All replies
-
User705563967 posted
check the code written inside the postback
better to share your code.
Wednesday, January 7, 2015 1:12 AM -
User-746270871 posted
protected void BtnOuvrirRapport(object sender, EventArgs e) { ReportDocument rptdoc = new ReportDocument(); examenTableAdapter adapter = new examenTableAdapter(); DataTable dt = adapter.GetData(); rptdoc.Load(Server.MapPath("NB_EXAMNE_Report.rpt")); rptdoc.SetDataSource(dt); rptdoc.RecordSelectionFormula = "{examen.study_rv_date} in {?fromdate} to {?todate}"; Session["rd"] = rptdoc; rptdoc.Refresh(); } protected void Page_Load(object sender, EventArgs e) { Response.AppendHeader("Refresh", "900"); ReportDocument rd = (ReportDocument)Session["rd"]; CrystalReportViewer1.ReportSource = rd; CrystalReportViewer1.DataBind(); CrystalReportViewer1.RefreshReport(); CrystalReportViewer1.ReuseParameterValuesOnRefresh = true; GC.Collect(); }
Wednesday, January 7, 2015 3:52 AM -
User705563967 posted
You did not pass rptdoc to Crystal report viewer on button click
used this command on button click because first page load is called then button click you calling report viewer on page load and set report parameter on function check below code
CrystalReportViewer1.ReportSource = rd;
CrystalReportViewer1.DataBind();
CrystalReportViewer1.RefreshReport();protected void BtnOuvrirRapport(object sender, EventArgs e) { ReportDocument rptdoc = new ReportDocument(); examenTableAdapter adapter = new examenTableAdapter(); DataTable dt = adapter.GetData(); rptdoc.Load(Server.MapPath("NB_EXAMNE_Report.rpt")); rptdoc.SetDataSource(dt); rptdoc.RecordSelectionFormula = "{examen.study_rv_date} in {?fromdate} to {?todate}"; Session["rd"] = rptdoc; CrystalReportViewer1.ReportSource = rd; CrystalReportViewer1.DataBind(); CrystalReportViewer1.RefreshReport(); }
Wednesday, January 7, 2015 4:11 AM -
User-746270871 posted
thanks for your reply,
but the code of button and page that contain crystalviewer it's not in the same page.aspx that's why i used session.
this code is not accepted in the page that contain the button...
CrystalReportViewer1.ReportSource = rd; CrystalReportViewer1.DataBind(); CrystalReportViewer1.RefreshReport(); }
Thursday, January 8, 2015 2:28 AM -
User705563967 posted
call the same button code on page load without using selection formula and check it is working fine
Saturday, January 10, 2015 11:52 PM