Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
System.NullReferenceException


An exception of type 'System.NullReferenceException' occurred in Online.dll but was not handled in user code

Additional information: Object reference not set to an instance of an object.


What I have tried:

This Is My Code
How to Fix It
protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                CDT = Cadapter.SELECT_SEARCH_COMPANY(Session["CCate"].ToString(), Session["CQuali"].ToString(), Session["CSkill"].ToString());
                if (CDT.Rows.Count == 0)
                {
                    lblmsg.Text = "Result not Found !!!";
                }
                else
                {
                    DataList3.DataSource = CDT;
                    DataList3.DataBind();
                }
            }
Posted
Updated 16-Jun-17 5:31am

1 solution

Something in your code is resolving to a "null" and you are trying to access a property on it. We can't tell you what that is as we can't run your code, you'll need to use the debugger to find out what. It could be "Cadapter", or Session["CCats"], or Session["CQuali"] and so on.

Once you've found out what is null then how you solve it depends on what you want to do in that situation, which again we can't know, but it's going to involve code like

if (XYX == null}
{
   // take the appropriate action
}


This question is asked multiple times a day, google the error for many articles discussing this, please do your own basic research before asking a question.
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 16-Jun-17 12:52pm    
5ed; congratulations on your 100k reputation as well!
F-ES Sitecore 19-Jun-17 4:00am    
Thanks :) 50k of those points were dealing with null reference exceptions :D
Suvendu Shekhar Giri 20-Jun-17 21:44pm    
5Ed!
Congratulations for 100K :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900