我有一个问题。
Dim Maxis As String
'Dim MaxisExtra As String
Dim b As New ArrayList
Dim WS As New WebService1.Service1
Dim cnt As String
Dim MRWS As New MobileReload_WS.MobileReload_WS
cnt = WS.StockCountTelco(1, Session("Maxis"))
If CInt(cnt) >= CInt(DropDownList1.SelectedItem.Text) Then
Dim sLock As String
sLock = MRWS.LockAStock(1, 1, "Online", Session("Maxis"), DropDownList1.SelectedItem.Text)
Session("sLock") = sLock
If sLock = "" Then
PopupMsgBox("Unable to allocate Stock")
Else
Maxis = "Maxis" & ";" & Session("Maxis") & ";" & DropDownList1.SelectedItem.Text & ";" & Session("Cost")
'If MaxisExtra = "" Then
' b.Add(Maxis)
' Elseif
' MaxisExtra = MaxisExtra + Maxis
' b.Add(MaxisExtra)
'End If
End If
Else
PopupMsgBox("Not enough stock")
End If
b.Add(Maxis)
Session("Transaction") = b
End Sub
我第一次将字符串输入到arraylist中就可以了。但是当用户再次按下按钮时,它会替换第一个字符串。任何人都可以帮我如何根据我的编码将字符串保存到第二个插槽中?
答案 0 :(得分:0)
如果您正在谈论b
ArrayList
,那么您每次都会创建一个新的ArrayList
Session("Transaction")
也许你的意思是这样......
Dim b as ArrayList = Session("Transaction")
If b Is Nothing Then
b = new ArrayList
End If
...
Session("Transaction") = b
虽然很难准确说出来,因为你的代码非常混乱而且不清楚
答案 1 :(得分:0)
您将数组列表放在会话变量中,但您从未将其读回。您每次都创建一个新的数组列表,因此它将始终为空并替换前一个。
从会话变量中获取数组列表(如果有):
Dim b As ArrayList = Session("Transaction")
If b Is Nothing Then b = New ArrayList