如何更新ArrayList会话[] [英] how update ArrayList Session[]

查看:73
本文介绍了如何更新ArrayList会话[]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 请帮助我

我如何更新ArrayList Session []
''
对于例如
ArrayList项目=(ArrayList)Session ["mycart"];
CShoppingCartItem item =新的CShoppingCartItem();

填充会话时
////
项数= 1
idbook 61
intproduceid 61
不足1
名称c
///
我要查询更新

解决方案

而不是ArrayList ,我认为更适合使用List< t>这里.将其更改为

 List< cshoppingcartitem> items = < cshoppingcartitem>(); 

将您的商品添加到该列表中.当您要更新项目时,请遍历列表并找到该项目并进行更新.

  foreach (CshoppingCartItem cItem  项目中的对象)
{
  如果(条件)
  {
    item.inquntity =  2 ;
  }
} 


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

解决方案

Instead of ArrayList , I think it is more suitable for you to use a List<t> here. Change it to

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.

foreach(CShoppingCartItem cItem in items)
{
  if(condition)
  {
    item.inquntity = 2;
  }
}


这篇关于如何更新ArrayList会话[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆