Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
How to Store  and Retrieve  values stored in an Object  via  Session?

bll_out_300_cntrl OUT_300_CONTROL=new bll_out_300_cntrl();
<pre lang="C#">objOUT_300_CONTROL.SendingInstitutionIdentifier = txtSendingInstitutionIdentifier.Text.Trim();
objOUT_300_CONTROL.CreatedBy = decimal.Parse(Session[&quot;USER&quot;].ToString());
objOUT_300_CONTROL.Department = Convert.ToInt32(Session[&quot;SELECTED_DEPT&quot;]);</pre>

I want to store and fetch the values stored in object via Session or any other way.

What I have tried:

Created a class and added values to object of the corresponding one.
I am unable to get the values on calling after a button click in modal pop up. Want to store those values & fetch after a button click in modal pop up .
bll_out_300_cntrl OUT_300_CONTROL=new bll_out_300_cntrl();
<pre lang="C#">objOUT_300_CONTROL.SendingInstitutionIdentifier = txtSendingInstitutionIdentifier.Text.Trim();
objOUT_300_CONTROL.CreatedBy = decimal.Parse(Session[&quot;USER&quot;].ToString());
objOUT_300_CONTROL.Department = Convert.ToInt32(Session[&quot;SELECTED_DEPT&quot;]);</pre>
Posted
Updated 22-Feb-16 0:02am

Um...
C#
Session["UserData"] = myUserDataInstance;
...
UserDataClassName myUserDataInsteance = (UserDataClassName) Session["UserData"];
 
Share this answer
 
create one session variable and assign your data to session it will store in session variable and use it when you want to you but you need to convert session data into your data type For. E.g.
object data; -- here data is any data which you want to store in session
Session["Mydata"]= data;
.
.
.
.
.
at the time of use you need to convert session into object

object data2 = (object)Session["Mydata"];
 
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