问题描述
//这个是添加购物车内容的代码OrderItemInfoitem=newOrderItemInfo();OrderInfoorder=newOrderInfo();if(Session[Session.SessionID]==null){Session["id"]=Request.QueryString["id"].ToString();Session["Titlename"]=Request.QueryString["Titlename"].ToString();Session["Moneys"]=Request.QueryString["Moneys"].ToString();item.CommodityID=Session["id"].ToString();item.CommodityName=Session["Titlename"].ToString();item.CommodityMoney=Session["Moneys"].ToString();item.CommodityNumber=1;order.OrderItemList.Add(item);Session[Session.SessionID]=order;Response.Redirect("Buycar.aspx");}
//这是实体类的代码publicclassOrderItemInfo{publicstringCommodityID;///商品IDpublicstringCommodityName;publicstringCommodityMoney;publicintCommodityNumber;}publicclassOrderInfo{publicintTotalNumber;//总数publicdecimalTotalMoney;//总钱publicList<OrderItemInfo>OrderItemList=newList<OrderItemInfo>();//总商品列表}
解决方案
解决方案二:
//这是修改的代码OrderInfoorder=(OrderInfo)Session[Session.SessionID];intnText=-1;for(inti=0;i<order.OrderItemList.Count;i++){TextBoxtb=(TextBox)Repeater1.Items[i].FindControl("TextBox1");if(int.TryParse(tb.Text.ToString(),outnText)==false)return;if(nText<0)return;((OrderItemInfo)order.OrderItemList[i]).CommodityNumber=int.Parse(tb.Text.ToString());}Session[Session.SessionID]=order;Repeater1.DataSource=order.OrderItemList;Repeater1.DataBind();
删除一条数据怎样写求解......
解决方案三:
order.OrderItemList这个实体类应该有移除的方法吧?