Why crystal report required parameter again when p

2019-08-06 05:02发布

问题:

Dear all I am working on an asp .net application (Webform) in which I am using crystal report for showing reports (with store procedure ).

In my application everything works fine including the reports. The real problem comes when I start clicking on the crystal report toolbar. If I click on any buttons on the crystal report tool bar like (Export, next page ...etc.) it is asking parameters again. Is there any way so that that the crystal report viewer does not ask the parameter that I have already given ?

 ReportDocument r = new ReportDocument();
                r.Load(Server.MapPath("~/Consumers/Reports/JobOrder.rpt"));
                SqlParameter[] para= new SqlParameter[1];
                para[0]= new SqlParameter("@OrderId",JobOrder);
                dt=da.ExecuteQuery("sp_rpt_JobOrder",para);
                if(dt.Rows.Count>0)
                {
                    r.SetParameterValue("@OrderId", JobOrder);
                    r.SetDataSource(dt);
                    CrystalReportViewer1.ReportSource = r;
                }

can some one help me? Highly appreciated.

回答1:

its causing due to post back. so i removed

if (!Page.IsPostBack)

now its working fine for me.

Thank you.