Vishwas Kadamannaya

Vishwas Kadamannaya

  • 1.6k
  • 122
  • 142.7k

Session Variable Gets Changed

Apr 14 2011 8:45 AM
Hi All,
       Iam Using Session to pass values to another Page. Iam using ArrayList in Session.
In next page am deleting some list items 

In Session["ContrcatList"] i have around 20 items and i delete some items based on contractId which is unique for each item in array list, but when i again use Session["ContractList"] this get modified(ArrayList after deletion of some items) and i dont get the orginal value. How i will get original value and i need 2 modify Array list as well.


 ArrayList listOfContract = null;               
  listOfContract = (ArrayList)Session["ContractList"]; // here listOfContract.Count = 20

ArrayList ar1 = new ArrayList();
ar1 = listOfContract;
 ar1[0] = listOfContract[contractId];
 ar1.RemoveRange(1, ar1.Count - 1);

 ArrayList listOfContract1 = null;               
  listOfContract1 = (ArrayList)Session["ContractList"]; // here listOfContract.Count = 1;

Answers (3)