如何对类中的以下属性进行排序然后存储在一个ArrayList
?我已将其填充到一个,ArrayList
但是当页面重新加载时,转发器中的项目顺序会发生变化。这是数组中的人口 cookie 值
Dim myCookies As HttpCookie=HttpContext.Current.Request.Cookies("Mycard")
Dim varArryItems As ArrayList = New ArrayList
For i AsInteger=0 To varCookies.Values.Count-1
Dim AllValues As String()=myCookies.Values(i).Split("|"c)
Dim item As objCard=New objCard
item.P_ItemID=Integer.Parse(AllValues(0))
item.P_ItemTitle=AllValues(1).ToString
item.P_BrandTitle=AllValues(2).ToString
item.P_ItemImg=AllValues(3).ToString
item.P_ItemPrice=Decimal.Parse(AllValues(4))
'item.P_ItemQauntity=Integer.Parse(AllValues(5))
'item.P_ItemQauntitySelected=Integer.Parse(AllValues(6))
item.P_BarcodeID=Integer.Parse(AllValues(7))
item.P_TotalItemPrice=Decimal.Parse(AllValues(8))
varArryItems.Add(item)
Next
rptcart.DataSource=varArryItems
rptcart.DataBind()
这是我的objCard
类存储 cookie 值,我需要对我尝试使用ArrayList
Sort 方法的所有属性进行排序,但它对我不起作用。
Public Class objCard
Private ID As Integer
Private ItemID As Integer
Private BarcodeID As Integer
Private ItemTitle As String
Private BrandTitle As String
Private ItemImg As String
Private ItemPrice As Decimal
Private TotalItemPrice As String
Private ItemQauntity As Integer
Private ItemQauntitySelected As Integer
Public Property P_ID As Integer
Get
Return Me.ID
End Get
Set
Me.ID = Value
End Set
End Property
Public Property P_ItemID As Integer
Get
Return Me.ItemID
End Get
Set
Me.ItemID = Value
End Set
End Property
Public Property P_BarcodeID As Integer
Get
Return Me.BarcodeID
End Get
Set
Me.BarcodeID = Value
End Set
End Property
Public Property P_ItemTitle As String
Get
Return Me.ItemTitle
End Get
Set
Me.ItemTitle = Value
End Set
End Property
Public Property P_BrandTitle As String
Get
Return Me.BrandTitle
End Get
Set
Me.BrandTitle = Value
End Set
End Property
Public Property P_ItemImg As String
Get
Return Me.ItemImg
End Get
Set
Me.ItemImg = Value
End Set
End Property
Public Property P_ItemPrice As Decimal
Get
Return Me.ItemPrice
End Get
Set
Me.ItemPrice = Value
End Set
End Property
Public Property P_TotalItemPrice As String
Get
Return Me.TotalItemPrice
End Get
Set
Me.TotalItemPrice = Value
End Set
End Property
Public Property P_ItemQauntity As Integer
Get
Return Me.ItemQauntity
End Get
Set
Me.ItemQauntity = Value
End Set
End Property
Public Property P_ItemQauntitySelected As Integer
Get
Return Me.ItemQauntitySelected
End Get
Set
Me.ItemQauntitySelected = Value
End Set
End Property
End Class