locked
Next page is not working for new crystal report file RRS feed

  • Question

  • User-1124190270 posted

    I have recently created a report file. For that file the next page button is not working properly.

    My old reports are working perfectly.

    Here is my code

    protected void Page_Load(object sender, EventArgs e)
        {

    if (!IsPostBack)
                        {
                            Session["LvMatrixSession"] = null;

                            lbl_report_name.Text = "Leave Matrix Report";

                            frm = Request.QueryString["frm"];
                            to = Request.QueryString["to"];
                            if (Session["param"] == null)
                                break;
                            string[] par = Session["param"].ToString().Split('#');
                            Session["param"] = null;

                            comp = par[0];
                            dept = par[1];

                            //HF_SessionName.Value = "rptLeaveMatrix-" + DateTime.Now.ToString("yyMMddhhmmss");

                            Generate_LeaveMatrix_report(frm, to, comp, dept, rpt_LeaveMatrix);
                        }
                        else
                        {
                            ReportDocument doc = (ReportDocument)Session["LvMatrixSession"];
                            CrystalReportViewer1.ReportSource = doc;
                        }

    }

    private void Generate_LeaveMatrix_report(string frmDate, string toDate, string compCode, string deptCode, string report_Name)
        {
            try
            {
                DataSet ds = new DataSet();
                bll_TA_Reports objTARpt = new bll_TA_Reports();

                ds = objTARpt.Generate_LeaveMatrixReport(frmDate, toDate, compCode, deptCode);

                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    Alert.Show("No records found");
                    close_page();
                    return;
                }

                CrystalReportViewer1.RefreshReport();

                ParameterFields paramFields = new ParameterFields();

                ParameterField pfF1 = new ParameterField();
                pfF1.ParameterFieldName = "FmDt"; //Crystal Report Parameter name
                ParameterDiscreteValue pfV1 = new ParameterDiscreteValue();
                pfV1.Value = frmDate;
                pfF1.CurrentValues.Add(pfV1);
                paramFields.Add(pfF1);


                ParameterField pfF2 = new ParameterField();
                pfF2.ParameterFieldName = "ToDt"; //Crystal Report Parameter name
                ParameterDiscreteValue pfV2 = new ParameterDiscreteValue();
                pfV2.Value = toDate;
                pfF2.CurrentValues.Add(pfV2);
                paramFields.Add(pfF2);

                ParameterField pfF3 = new ParameterField();
                pfF3.ParameterFieldName = "myCompany"; //Crystal Report Parameter name
                ParameterDiscreteValue pfV3 = new ParameterDiscreteValue();
                pfV3.Value = D3.siteSettings.CompanyName;
                pfF3.CurrentValues.Add(pfV3);
                paramFields.Add(pfF3);

                CrystalReportViewer1.ParameterFieldInfo = paramFields;

                string path = Server.MapPath("~") + "\\Reports\\TimeAttendance\\" + report_Name;
                ReportDocument cr = new ReportDocument();
                cr.Load(path);
                cr.SetDataSource(ds);
                CrystalReportViewer1.ReportSource = cr;
                Session["LvMatrixSession"] = cr;

                if (ds != null)
                    ds.Dispose();


            }
            catch (Exception ex)
            {          
                ErrorLog.LogError(ex);
                Alert.Show(ex.Message);
            }
        }  

    Thursday, October 29, 2015 8:31 AM

All replies

  • User-219423983 posted

    Hi benitoxavier,

    For that file the next page button is not working properly

    My old reports are working perfectly.

    If the following code could work perfectly, the following code logic is right. You could first debug your code in the new page to find out why the button is not working, then compare with the old one to find out the differences. After solving the differences, try again. Besides, in your code, I couldn’t find which line would impact the “Button”, you’d better provide the corresponding codes.

    I hope it’s useful to you.

    Best Regards,

    Weibo Zhang

    Tuesday, November 10, 2015 6:37 AM