[Solved] ASP.Net Crystal Report Viewer not displaying (showing) in browser

trisetia302
 
on Jul 07, 2021 10:49 PM
Sample_101542.zip
8216 Views

Hi Guys,

I'm trying to print invoice in Report Viewer, but the button print not showing even though already set "ShowPrintButton =true" in Report Viewer.

I have try many way to find the solution for get best print result, but using report viewer until now I'm not find the solution sir, and the I'm decided to use CrystalReportViewer to try solve my problem.

But I'm get problem CrystalReportViewer not show the result.

Any help could be appreciate.

public partial class Reporting_CetakBuktiSimpanan : System.Web.UI.Page
{
    string koneksi = System.Configuration.ConfigurationManager.ConnectionStrings["db_koperasiConnectionString"].ConnectionString.ToString();
    ReportDocument _ReportDocument = new ReportDocument();
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    private void ShowDataToPrint()
    {
        using (SqlConnection con = new SqlConnection(koneksi))
        {
            using (SqlCommand cmd = new SqlCommand())
            {
                try
                {
                    con.Open();
                    cmd.Connection = con;
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = "Select * From View_Cetak_Bukti_Simpanan";
                    SqlDataAdapter adap = new SqlDataAdapter(cmd);
                    DataSet ds = new DataSet();
                    adap.Fill(ds,"DataTable_Cetak_Bukti_Simpanan");
                    _ReportDocument.Load(Server.MapPath("~/RptReport/ReportCetakBuktiSimpanan.rpt"));
                    _ReportDocument.SetDataSource(ds);
                    CrystalReportViewer1.ReportSource =_ReportDocument;
                    CrystalReportViewer1.RefreshReport();
                    CrystalReportViewer1.DisplayToolbar = true;
                    con.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
    }
    protected void BtnPrintStrukBuktiSimpanan_Click(object sender, EventArgs e)
    {
        ShowDataToPrint();
    }
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Jul 09, 2021 07:24 AM

Hi trisetia302,

1. Install proper Crystal Reports Runtime.

2. Copy the Crystal Report Support files to your Website Root Directory.

3. You need to place the script tag in the Head section of the page or Master Page if you are using Master Pages.

<script src='<%=ResolveUrl("~/crystalreportviewers13/js/crviewer/crv.js")%>' type="text/javascript"></script>

With this fix the Crystal Reports will start working.

Refer below article for complete steps.

Crystal Reports Bobj is undefined and bobj.isObject is not a function in Visual Studio 2012 and 2013