Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;



namespace MPOffice
{
public partial class EmpReport : System.Web.UI.Page
{
RptEmployee rpt;
protected void Page_Load(object sender, EventArgs e)
{


}
protected void Page_Init(object sender, EventArgs e)
{
if (Session["report"] != null)
{
CrystalReportViewer1.ReportSource = (RptEmployee)Session["report"];
}
}
protected void Button1_Click(object sender, EventArgs e)
{
MPEmployeeTableAdapters.EMP_DATATableAdapter da = new
MPEmployeeTableAdapters.EMP_DATATableAdapter();
MPEmployee ds = new MPEmployee();
MPEmployee.EMP_DATADataTable dt =
(MPEmployee.EMP_DATADataTable)ds.Tables["EMP_Data"];

da.Fill(dt);

rpt = new RptEmployee();
rpt.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rpt;
Session.Add("report", rpt);


}


}
}

What I have tried:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmpReport.aspx.cs" Inherits="MPOffice.EmpReport" %>

<%@ Register assembly="CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>

<!DOCTYPE html>



<title>

EmpReport.aspx




<asp:Button ID="BtnShowRpt" runat="server" OnClick="Button1_Click" Text="Show Data" />
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="True" GroupTreeImagesFolderUrl="" Height="1202px" ReportSourceID="CrystalReportSource1" ToolbarImagesFolderUrl="" ToolPanelWidth="200px" Width="1104px" EnableDatabaseLogonPrompt="False" EnableParameterPrompt="False" />
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="C:\Users\ACER_VERITON\source\repos\MPOffice\MPOffice\RptEmployee.rpt">
Posted
Updated 16-Aug-18 3:25am

1 solution

The quickest way is figure out why it's not displaying is to use the debugger to step into your code. You would need to see the DataSource for your Report if it contains data or not.

Quote:
<Report FileName="C:\Users\ACER_VERITON\source\repos\MPOffice\MPOffice\RptEmployee.rpt">


Another thing to notice is that you were referencing a file that is outside your Project root which can potentially cause an access issue. Try to move your Report file .rpt within your project root and reference it from there.

Here are a couple of tutorials I found on google on how to work with Crytal Reports in ASP.NET:

How to Create Crystal Reports in ASP.NET Webforms[^]

Create Crystal Reports Report in ASP.Net
 
Share this answer
 

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