Click here to Skip to main content
15,560,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am showing data in the Crystal Report. In the crystal report entire rpt field data is coming fine. But while exporting to PDF/Excel few rpt field data are not coming . I am using asp.net with c#. I am using Crystal report with version 10.5.3700.0

What I have tried:

My Code is as below:
ReportDocument reportDocument;
   int selectedDB = 0;
   protected void Page_Load(object sender, EventArgs e)
   {
       try
       {
           // -- Modified by Yahudha James on 15th July 2019 for DDS Enhancements 2017 -- // -- BEGIN -- //
           foreach (Control div in Master.FindControl("DDSEdgeHeader1").Controls)
           {
               if (div.GetType().Name == "HtmlGenericControl" && div.ID == "divDB")
               {
                   foreach (Control rb in div.Controls)
                   {
                       if (rb.GetType().Name == "RadioButtonList" && rb.ID == "rbDatabase")
                       {
                           RadioButtonList rbDatabase = (RadioButtonList)rb;
                           selectedDB = Convert.ToInt32(rbDatabase.SelectedValue);
                       }
                   }

               }
           }
           // -- Modified by Yahudha James on 15th July 2019 for DDS Enhancements 2017 -- // -- END -- //
           //check for valid user
           //if (!IsLoggedIn)
           //    return;
            if (!IsPostBack)
           {
               ClearControl();
               PopulateBank();
               PopulateInstructionCode();

           }
           else
           {
               if (validation())
                   ViewReport();
           }



       }
       catch (Exception ex)
       {
           Common.handleErrorLog(ex);
       }
   }

#region CrystalReportCtrlSettings
  /// <summary>
  /// CrystalReportCtrlSettings
  /// </summary>
  /// <param name="CrptViewReport"></param>
  private void CrystalReportCtrlSettings(CrystalReportViewer CrptViewReport)
  {
      CrptViewReport.HasGotoPageButton = false;
      CrptViewReport.DisplayGroupTree = false;
      CrptViewReport.HasGotoPageButton = false;
      CrptViewReport.HasSearchButton = false;
      CrptViewReport.HasDrillUpButton = false;
      CrptViewReport.HasViewList = false;
      CrptViewReport.Width = 0;

      CrptViewReport.HasCrystalLogo = false;
      CrptViewReport.HasToggleGroupTreeButton = false;
      CrptViewReport.HasZoomFactorList = false;
      CrptViewReport.Zoom(90);
      Style stlCRV = new Style();
      stlCRV.Width = Common.RPT_WIDTH_LANDSCAPE;
      CrptViewReport.ToolbarStyle.MergeWith(stlCRV);

  }
  #endregion

#region View Report
   /// <summary>
   /// Function to view the report
   /// </summary>
   protected void ViewReport()
   {
       try
       {
           //Setting the crystal report controls.
           CrystalReportCtrlSettings(CRVRUserListReport);
           //set the report path
           string reportPath = Server.MapPath("~//Reports//OutwardDDASummaryReport.rpt");
           BLL_MISReports objclass = new BLL_MISReports();

           string FromDate = DateTime.ParseExact(txtStartDate.Value.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy/MM/dd");
           string ToDate = DateTime.ParseExact(txtEndDate.Value.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy/MM/dd");
           //COmmented and Added on 21-12-15 for BusinessChanges
           string ContractRefNo = txtContractReferenceneNo.Value;
           string Accno = txtAccountNo.Value;
           //DataSet ds = objclass.getOutwardDDASummaryReport(ddlPayingBankId.SelectedValue, drdInstructionCode1.SelectedValue,FromDate, ToDate);
           DataSet ds = objclass.getOutwardDDASummaryReport(ddlPayingBankId.SelectedValue, drdInstructionCode1.SelectedValue, FromDate, ToDate, ContractRefNo,selectedDB,Accno,txtNBCPDFRefNo.Value);

           DataTable dt = new DataTable();
           if (ds.Tables[0].Rows.Count > 0)
           {
               dt = ds.Tables[0];
               CRVRUserListReport.Visible = true;
           }
           else
           {
               CRVRUserListReport.Visible = false;
               Common.showMessage("No Records Found", this);
               return;
           }

           //--Initializing CrystalReport
           reportDocument = new ReportDocument();
           reportDocument.Load(reportPath);
           reportDocument.SetDataSource(dt);

           //Passing Date Criteria for display in Report header
           reportDocument.SetParameterValue("@FromDate", txtStartDate.Value);
           reportDocument.SetParameterValue("@ToDate", txtEndDate.Value);
           reportDocument.SetParameterValue("@PrintUser",  Session["USER_NAME"].ToString());
           if (ddlPayingBankId.SelectedIndex > 0)
           {
               reportDocument.SetParameterValue("@PayingBankID", ddlPayingBankId.SelectedItem.Text);
           }
           else
           {
               reportDocument.SetParameterValue("@PayingBankID", "");
           }

           if (drdInstructionCode1.SelectedIndex > 0)
           {
               reportDocument.SetParameterValue("@InstructionCode", drdInstructionCode1.SelectedItem.Text);
           }
           else
           {
               reportDocument.SetParameterValue("@InstructionCode", "");
           }


           //--Binding report with CrystalReportViewer
           CRVRUserListReport.ReportSource = reportDocument;
           CRVRUserListReport.DataBind();

       }
       catch (Exception ex)
       {
           Common.handleErrorLog(ex);
       }
   }
   #endregion
Posted
Comments
Maciej Los 23-Feb-22 11:03am    
Have you tried to debug your code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900