CrystalReportViewer - manually creating the object

M

Marc Callec

I'm trying to create an instance of the CrystalReportViewer control
within my class in an attempt to return the rendered HTML back to the
consumer of the class. Because I haven't added the
CrystalReportViewer control directly to a web page, but have
instantiated in manually I've explicitly called the OnLoad, OnInt,
OnPreRender and OnUnload in an attempt to get the control to be
initialised correctly.

Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New
System.Web.UI.HtmlTextWriter(stringWrite)

MyBase.OnInit(e)
MyBase.ReportSource = "C:\Sample2.rpt"
MyBase.OnLoad(e)

MyBase.Render(htmlWrite)

MyBase.OnPreRender(e)
MyBase.OnUnload(e)

return stringWrite.ToString


The returned HTML renders the Crystal toolbar and the area where the
report should be is yellow and includes the text - CrystalViewer
Error: Object reference not set to an instance of an object.

So, it looks like there is still something I need to set in the
control, but I don't have any idea what that might be. I'm thinking
it may be viewstate or the page context - something that ASP.Net would
usually set up for the control.

FYI - I'm not using the ReportDocument object to export the HTML
becuause I need to have the ability to drill down, which the export
function doesn't do.

Does anyone have any ideas or suggestions for manually setting up the
CrystalReportViewer control correctly? I've spent a few days trying
to get this to work, so I'm getting a little frustrated at the moment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top