By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

CrystalReportViewer - manually creating the object

P: n/a
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.
Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.