Click here to Skip to main content
15,936,349 members
Please Sign up or sign in to vote.
3.50/5 (3 votes)
Hi,

anybody tell me how can i check session is storing value or not?

actully i am using first time session variable to store datatable gridview but do't know that is saving value or not actully in my grid when user inser first row entry then it is ok when click on new row button then new row generate but previous row value lost.

Suggest how can i check it??

Thanks
Posted
Comments
Vigneshb6 12-Nov-10 5:37am    
arey yaar check if(Session["UserName"]!=null)
{
}
and put the break point you will get to know.
Ashika s 15-Nov-10 2:10am    
ya...........
its good answer.....

Hi,

if you want to check whether variable is stored in session, just test it for null as was posted earlyer. try to check following link:
http://msdn.microsoft.com/en-us/library/ms972429.aspx[^]

in this article is session explained.
 
Share this answer
 
Already Abdul gave you easy snippet for you anyway go through this

Storing and Retrieving values from Session[^]
 
Share this answer
 
C#
C#
if (Session["YourSessionName"] !=null)
{
}


VB.NET
C#
If Not Session("YourSessionName") Is Nothing Then
End IF
 
Share this answer
 
v2
Comments
call to .net 11-Nov-10 7:12am    
can u explain in brief??
Abdul Quader Mamun 11-Nov-10 7:16am    
if (Session["YourSessionName"] !=null)
{
}
YourSessionName is the session which you want to check whether it is exist or not. If exist then write the body of the if condition.
Abdul Quader Mamun 11-Nov-10 7:22am    
Session["YourSessionName"]=Somevalue;
By the code you can create session.
call to .net 11-Nov-10 7:47am    
thanks for yr quick reply and i understand how it works but
i am unable to implement have u any sample example for such program.
Abdul Quader Mamun 11-Nov-10 7:49am    
OK. which language you using C# or VB.NET
plz check
if(session["username"]!=null)
{
}
i think this may help for u...........
 
Share this answer
 
Comments
Manfred Rudolf Bihy 12-Aug-11 11:11am    
Copy cat strikes again. Punished!

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



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