tnakamur
asked on
I get an error: Object reference not set to an instance of an object
Hi, I'm getting the error:
"Object reference not set to an instance of an object"
Exception Details: System.NullReferenceExcept ion: 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.displa yMenu() in c:\inetpub\wwwroot\loadrun ner\webfor m1.aspx.cs :591
LoadRunner.WebForm1.Page_L oad(Object sender, EventArgs e) in c:\inetpub\wwwroot\loadrun ner\webfor m1.aspx.cs :319
System.Web.UI.Control.OnLo ad(EventAr gs e)
System.Web.UI.Control.Load Recursive( )
System.Web.UI.Page.Process RequestMai n()
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( "applicati on.xml"));
//Choose the "batchfile"
DataView view = ds.Tables["batchfile"].Def aultView;
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\loadru nner\) and is valid. I just can't seem to figure out why "batchList.DataSource = view" can be generating an error.
Thank you very much.
"Object reference not set to an instance of an object"
Exception Details: System.NullReferenceExcept
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.displa
LoadRunner.WebForm1.Page_L
System.Web.UI.Control.OnLo
System.Web.UI.Control.Load
System.Web.UI.Page.Process
The code is as following, where batchList is declared
protected System.Web.UI.WebControls.
==
private void displayMenu()
{
//read the Xml into DataSet.
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(
//Choose the "batchfile"
DataView view = ds.Tables["batchfile"].Def
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\loadru
Thank you very much.
>>new need to set you variable to an instance of the object. (??)
YOU need to set YOUR ..... holy fat fingers batman!
ASKER
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.FindContro l("check1" )).Enabled = false;
}
Any ideas on this one?
foreach(DataGridItem item in batchList.Items)
{
//this line now
((CheckBox)item.FindContro
}
Any ideas on this one?
Make sure you included in your aspx page:
<asp:DataGrid id="batchList" runat="server">
....
</asp:DataGrid>
<asp:DataGrid id="batchList" runat="server">
....
</asp:DataGrid>
oops... posted right after you replied
As for your last post... make sure check1 included in your aspx page and/or declared.
As for your last post... make sure check1 included in your aspx page and/or declared.
Hmmm... this should work.
I'll have to run some tests to see if I can reproduce the error
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
or
protected System.Web.UI.WebControls.