Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I get an error:  Object reference not set to an instance of an object

Posted on 2004-04-02
7
Medium Priority
?
974 Views
Last Modified: 2008-02-01
Hi, I'm getting the error:  
"Object reference not set to an instance of an object"

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:
Line 589:                        StatusBox.Text = "view is not null";
Line 590:                  
Line 591(this line):                  batchList.DataSource = view;
Line 592://                  batchList.DataBind();
Line 593:            }

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   LoadRunner.WebForm1.displayMenu() in c:\inetpub\wwwroot\loadrunner\webform1.aspx.cs:591
   LoadRunner.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\loadrunner\webform1.aspx.cs:319
   System.Web.UI.Control.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()


The code is as following, where batchList is declared
protected System.Web.UI.WebControls.DataGrid batchList;

==
            private void displayMenu()
            {
                  //read the Xml into DataSet.
                  DataSet ds = new DataSet();
                  ds.ReadXml(Server.MapPath("application.xml"));

                  //Choose the "batchfile"
                  DataView view = ds.Tables["batchfile"].DefaultView;
                  view.Sort = "order" + " DESC";
                  
                  if(view==null)
                        StatusBox.Text = "view is null";
                  else
                        StatusBox.Text = "view is not null";
                  
                  batchList.DataSource = view;
                  batchList.DataBind();
==
This code was working perfectly before, and now it doesn't.  application.xml exists in the appropriate directory (c:\inetput\wwwroot\loadrunner\) and is valid.  I just can't seem to figure out why "batchList.DataSource = view" can be generating an error.

Thank you very much.
0
Comment
Question by:tnakamur
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 22

Expert Comment

by:_TAD_
ID: 10744732


new need to set you variable to an instance of the object.

That is, get a currently running instance, or create a new one


protected System.Web.UI.WebControls.DataGrid batchList = new DataGrid();

or

protected System.Web.UI.WebControls.DataGrid batchList = DataGrid1; // assuming that you have a datagrid1 on your form
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 10744747


>>new need to set you variable to an instance of the object.    (??)

YOU need to set YOUR .....  holy fat fingers batman!  

0
 

Author Comment

by:tnakamur
ID: 10744881
Ahh.  That's gone, but I get the exact same error in the different part of the code:

foreach(DataGridItem item in batchList.Items)
{
                //this line now
      ((CheckBox)item.FindControl("check1")).Enabled = false;
}

Any ideas on this one?
      
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:gillit
ID: 10744888
Make sure you included in your aspx page:
<asp:DataGrid id="batchList" runat="server">
    ....
</asp:DataGrid>
0
 
LVL 3

Expert Comment

by:gillit
ID: 10744910
oops... posted right after you replied

As for your last post... make sure check1 included in your aspx page and/or declared.
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 10746114


Hmmm... this should work.


I'll have to run some tests to see if I can reproduce the error
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 450 total points
ID: 10746636
I think your problems are all with the controls. In the first problem, the null value was probably batchList and not the view. Now you have another problem with a control. Review your HTML code to see if all controls are declared correctly and they are configured to run on the server
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question