Click here to Skip to main content
15,900,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, How to get the session value in the where condition of the select command in details view
Posted

Please Add you code in your question so that we can better help you.

For design you can add session value in hidden field.And you can get hidden field value.

In code behind you can easily get session value session["SessionName"]
 
Share this answer
 
Hi,
Advise you to have an extra care when using session, cause session expires. When session expire on time the session value becomes null. The good coding is upon page load on your details page, you must store such value of session eg. hidden fields a suggested storage...

You can retrieve session value as example:

example:

C#
//Store user id in session
session[UserId"] = "MyUserId";


Assuming the name of your hidden field is hfUserId and upon loading on your display page you must store the value in your hidden field so that the value will not became null when session expires.

Example:
C#
this.hfUserId.value = session[UserId"] ;


Then you may retrieve the value of hidden field to be use in your select where clause...

Regards,
 
Share this answer
 
getting session value from textbox1 from default page 1:

Session["em"] = TextBox1.Text.ToString();

retrieve from database regarding session value from page 2:
string text2 = (String)Session["em"];

select query:

SqlCommand cmd = new SqlCommand("select * from user_detail where email='" + text2 + "'", con);
 
Share this answer
 
Hi,

Please post your code to find the solution. You can specify the the SelectParameters with select command where you can get vale from session and use that. For example see the link below,
http://msdn.microsoft.com/en-us/library/ms227560.aspx[^]
or alternatively you can specify the select command with session value from code behind (*.aspx.cs) file.
 
Share this answer
 

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