Advertisement

05.26.2008 at 03:16AM PDT, ID: 23432381
[x]
Attachment Details

Object reference not set to an instance of an object Control Collection

Asked by Steven_Prescott in .NET Framework 2.0, C# Programming Language, Programming for ASP.NET

Tags: c# asp.net reportviewer, IE6

I am using VS2005 (without SP1) and have the following problem.
I have a page that is using report viewer and need to use a number of different report definitions. Because I have not got SP1 installed I can't use the ReportViewer.Reset() method so am getting around this the following way...
ControlCollection coll = ReportViewer1.Parent.Controls;
int oldReportIndex = coll.IndexOf(ReportViewer1);
coll.Remove(ReportViewer1);
coll.AddAt(oldReportIndex, newReportViewer);
This works almost all of the time, however, occasionally I get the "Object reference not set to an instance of an object" on the "ControlCollection coll = ReportViewer1.Parent.Controls" line. I am guessing that it is because the ReportViewer1.Parent.Controls is null....
Does anyone have a nice way of getting around this problem?
Any help on this would be appreciated
Thanks in advanceStart Free Trial
 
 
[+][-]05.26.2008 at 05:24AM PDT, ID: 21645998

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.0, C# Programming Language, Programming for ASP.NET
Tags: c# asp.net reportviewer, IE6
Sign Up Now!
Solution Provided By: josgood
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.05.2008 at 07:28AM PDT, ID: 21719838

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628