Click here to Skip to main content
15,909,656 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have stored hash table in a session variable now i want to retrieve its data on other page in different labels.
Posted
Updated 3-Dec-13 22:41pm
v2
Comments
Salman622 4-Dec-13 4:47am    
can you explain little bit more about your problem

See this : http://forums.asp.net/t/1353450.aspx[^] Remember, you should not store large data into session.
 
Share this answer
 
Comments
uditCsharp 4-Dec-13 5:00am    
thank you very much.
Thanks7872 4-Dec-13 5:01am    
You are welcome.
uditCsharp 4-Dec-13 6:23am    
but can u please tell me why should not store large data into session?
Thanks7872 4-Dec-13 6:38am    
Because session will be stored on server which will consume more memory. One thing you can do is to store session in SQL Server.
uditCsharp 4-Dec-13 7:06am    
ok... thank you once again.
As the hastable stores the keyvaluespair values, you have to store keyvalue pair in hastable.
refer the following example for the same.. in this example i am storing data in session variable from one page and access it in to another page.

hope this will help you.

default.aspx.cs

C#
public partial class _Default : System.Web.UI.Page
   {
       protected void Page_Load(object sender, EventArgs e)
       {

           try
           {
               Dictionary<int, string> dict = new Dictionary<int, string>();
               dict.Add(1, "value1");
               dict.Add(2, "value2");
               Hashtable ht = new Hashtable(dict);
               Session["data"] = ht;
               Response.Redirect("default2.aspx", false);
           }
           catch (Exception)
           {
               throw;
           }
       }
   }



default2.aspx.cs


C#
public partial class default2 : System.Web.UI.Page
   {
       protected void Page_Load(object sender, EventArgs e)
       {
           if (Session["data"] != null)
           {
               Hashtable ht = Session["data"] as Hashtable;


           }
       }
   }
 
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