Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NullReferenceExcepion using Report Viewer with ASP.NET

Status
Not open for further replies.

sgprice78

IS-IT--Management
Jun 20, 2001
15
CA
I am trying to add a Crystal Report to an asp.net page but keep getting a NullReferenceException when I run the page. I have tried with several different reports, including a report with nothing more than a label. There is nothing else on the page.

Here is my aspx file:

<%@ Register TagPrefix=&quot;cr&quot; Namespace=&quot;CrystalDecisions.Web&quot; Assembly=&quot;CrystalDecisions.Web, Version=9.1.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304&quot; %>
<%@ Page language=&quot;c#&quot; Codebehind=&quot;index.aspx.cs&quot; AutoEventWireup=&quot;false&quot; Inherits=&quot;EPAEvalReports.index&quot; %>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot; >
<HTML>
<HEAD>
<title>index</title>
<meta name=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 7.0&quot;>
<meta name=&quot;CODE_LANGUAGE&quot; Content=&quot;C#&quot;>
<meta name=&quot;vs_defaultClientScript&quot; content=&quot;JavaScript&quot;>
<meta name=&quot;vs_targetSchema&quot; content=&quot; </HEAD>
<body>
<form id=&quot;index&quot; method=&quot;post&quot; runat=&quot;server&quot;>
<CR:CrystalReportViewer id=CrystalReportViewer1 runat=&quot;server&quot; Width=&quot;1030px&quot; Height=&quot;1079px&quot; ReportSource='<%# &quot;c:\\inetpub\\ %>'>
</CR:CrystalReportViewer>
</form>
</body>
</HTML>







And here is my code behind file:


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;

namespace EPAEvalReports
{
/// <summary>
/// Summary description for index.
/// </summary>
public class index : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
DataBind();

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top