Friday, September 30, 2011

How to Store Multiple Value In Session using asp.net c#

We can add multiple values by using class entiry or hashtable or arralist:
Here a we will use Hashtable for storing multiple value in session

Hashtable htEmpInfo = new Hashtable();

htEmpInfo.Add("Name", "Santosh");
htEmpInfo.Add("Designation", "SE");
htEmpInfo.Add("Department", "MS");

session["EmpDetails"]=htEmpInfo;

Retrieving the values from the session

Hashtable htEmpInformaiton = (Hashtable)session["EmpDetails"];
lblEmopName.Text=htEmpInformaiton["Name"].ToString();
lblDesignation.Text=htEmpInformaiton["Designation"].ToString();