Solved

Object reference not set to an instance of an object.

Posted on 2006-06-29
3
851 Views
Last Modified: 2008-01-09
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
Comment
Question by:jemigossaye
3 Comments
 
LVL 25

Accepted Solution

by:
dstanley9 earned 300 total points
ID: 17012562
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
 
LVL 12

Assisted Solution

by:topdog770
topdog770 earned 200 total points
ID: 17012640
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
 

Author Comment

by:jemigossaye
ID: 17012737
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now