Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi please help me

i am how update ArrayList Session[]
'
for exmaple
ArrayList items = (ArrayList)Session["mycart"];
CShoppingCartItem item = new CShoppingCartItem();

when fill session
////
item count=1
idbook 61
intproduceid 61
inquntity 1
name c
///
i am want inquntity update
Posted
Comments
Orcun Iyigun 5-Apr-12 14:24pm    
Can you elaborate it more?
saeed1364 5-Apr-12 14:32pm    
how ArrayList To change a value
Orcun Iyigun 5-Apr-12 15:35pm    
Let me explain you what I understood so far. You have an arraylist. You fill this array list with the session value. From this array list you want to update an item? What is the type of the arraylist? "CShoopingCartItem"?
Reza Ahmadi 5-Apr-12 14:58pm    
Saeed, it does not make any sense actually. I kindly ask you to try to describe your problem more clearly.
saeed1364 5-Apr-12 16:06pm    
ArrayList items = (ArrayList)Session["mycart"];
CShoppingCartItem item = new CShoppingCartItem();
ImageButton btn = (ImageButton)sender;
string[] CommandArgument = btn.CommandArgument.Split(',');
idbookbuy =Convert.ToInt32(CommandArgument[0]);
txtnamee = CommandArgument[1];
txtName = CommandArgument[2]; Session["mycart"] = arr;
item.ProductName = txtName;
item.ProductNameE = txtnamee;
item.UnitPrice = decimal.Parse(CommandArgument[3]);
item.Quantity = 1;
item.idbook = idbookbuy;
arr.Add(item);

1 solution

Instead of ArrayList , I think it is more suitable for you to use a List<t> here. Change it to
C#
List<cshoppingcartitem> items = new <cshoppingcartitem>();
add your items to that list. When you want to update an item loop through the list and find the item and update it.

C#
foreach(CShoppingCartItem cItem in items)
{
  if(condition)
  {
    item.inquntity = 2;
  }
}
 
Share this answer
 
v3
Comments
saeed1364 6-Apr-12 0:33am    
ok.how to change .how to find item then change
Orcun Iyigun 6-Apr-12 11:46am    
see the updated code please

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