Click here to Skip to main content
14,664,481 members
Rate this:
Please Sign up or sign in to vote.
See more:

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 !!!";
                    DataList3.DataSource = CDT;
Updated 16-Jun-17 5:31am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
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
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100