我有两个sortedlist一个商店产品信息和另一个商店服务如何使用Session.Contents Collection来提取这两个sortlist中的数据谢谢
代码 服务分类列表
Dim CartItemService As New CartItem
CartItemService.objService = objTempCartService
Me.AddToCart(CartItemService)
Private Sub AddToCart(ByVal CartItem As CartItem)
Dim CartService As SortedList = GetCart()
Dim ServiceID As Integer = objTempCartService.ServiceId
Dim Servicekey As String = "s" & CType(ServiceID, String)
If CartService.ContainsKey(Servicekey) Then
CartItem = CType(CartService(Servicekey), CartItem)
Else
CartService.Add(Servicekey, CartItem)
End If
End Sub
Private Function GetCart() As SortedList
If Session("CartS") Is Nothing Then
Session.Add("CartS", New SortedList)
End If
Return CType(Session("CartS"), SortedList)
End Function
产品分类列表
Dim CartItem作为新的CartItem CartItem.objProduct = objTempCart Me.AddToCart(CartItem)
End Sub
Private Sub AddToCart(ByVal CartItem As CartItem)
Dim Cart As SortedList = GetCart()
Dim sProductID As Integer = objTempCart.ProductId
Dim k As String = "P" & CType(sProductID, String)
If Cart.ContainsKey(k) Then
CartItem = CType(Cart(k), CartItem)
CartItem.objProduct.OrderQty = CartItem.objProduct.OrderQty + 1
CartItem.objProduct.Total = CartItem.objProduct.OrderQty * CartItem.objProduct.ProductPrice
Else
Cart.Add(k, CartItem)
CartItem.objProduct.OrderQty = 1
CartItem.objProduct.Total = CartItem.objProduct.OrderQty * CartItem.objProduct.ProductPrice
End If
End Sub
Private Function GetCart() As SortedList
If Session("Cart") Is Nothing Then
Session.Add("Cart", New SortedList)
End If
Return CType(Session("Cart"), SortedList)
End Function