i'm storing the DataTable information into Session
. in the same page i'm calling that Session obj.
gbds = ((DataTable)Session["datatable"]).Clone();
i have a data in my session object. sometimes it's working fine but sometimes its show the error " Object reference not set to an instance of an object "
i know the session Default timeout is 20min, but my browser ideal time is just 1 or 2 min. In that also it's shows that error message. for that i run that application in sharepoint site but here also it's shows the same problem. What's the wrong in that can any one help me what's the problem on here.
Thankx in advance...
This exception simply means that —SA
Session["datatable"] is null. You are trying to dereference this object by calling
.Clone() with this instance, but it cannot be done as the instance is null; this is exactly what throws this exception. You did not add any value by the index
"datatable", or misspelled it, something like that.
In general case, is some object is supposed to by non-null, make sure it is initialized (in case of sessions, it could be in a different page). Alternatively, check an object for null before dereferencing it, and do something else in case of null.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)