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
{
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);
}
}
}
}
if (!IsPostBack)
{
ClearControl();
PopulateBank();
PopulateInstructionCode();
}
else
{
if (validation())
ViewReport();
}
}
catch (Exception ex)
{
Common.handleErrorLog(ex);
}
}
#region CrystalReportCtrlSettings
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
protected void ViewReport()
{
try
{
CrystalReportCtrlSettings(CRVRUserListReport);
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");
string ContractRefNo = txtContractReferenceneNo.Value;
string Accno = txtAccountNo.Value;
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;
}
reportDocument = new ReportDocument();
reportDocument.Load(reportPath);
reportDocument.SetDataSource(dt);
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", "");
}
CRVRUserListReport.ReportSource = reportDocument;
CRVRUserListReport.DataBind();
}
catch (Exception ex)
{
Common.handleErrorLog(ex);
}
}
#endregion