• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 873
  • Last Modified:

Object reference not set to an instance of an object.

Hello,

i am using the infragistics web tree controled and on my page load I am having  this error
Object reference not set to an instance of an object. the line that is causing it is below

igTree.Nodes[0].Selected =true ;

here is my page_load code
 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            lblId.Text = Request["ParentTitle"];
                               
             LoadTree(Request["ParentTitle"]);
            igTree.Nodes[0].Selected =true ;
           
            PopulateUnassignedData();
                                   
         }
         AdminID = Session["admin_id"].ToString();
     }
0
jemigossaye
Asked:
jemigossaye
2 Solutions
 
dstanley9Commented:
then either igTree or igTree.Nodes[0] is null.  Run it in the debugger and see which is null.  What is the code for LoadTree?
0
 
topdog770Commented:
Yeah... it's likely that even if you are do a igTree = new 'WhatEverTheObjectNameIs'
that the nodes haven't been added the first time into the page.

Without seeing the code behind this.. I'd think that you will either need to add the node, first, OR make sure that the LoadTree function is working the way it's supposed to prior to setting the Selected value to true..

Simple check.. that may not provide the functionality you need long term would be to do something like this...

if( igTree != null && igTree.Nodes != null && igTree.Nodes.Count > 0 )
      igTree.Nodes[0].Selected =true ;

0
 
jemigossayeAuthor Commented:
okay thanks I had done some major damage to myself the loadtree was not retruning any values rather i wasn't retruning my dataset. what a day


thanks all
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now