D
David Lozzi
Howdy,
I have a shopping cart in my arraylist. Works great for adding items but I'm
displaying the shopping cart in a gridview and the user can update the qty
of the items. If they set it to 0, then I want to remove it. I'm doing the
following script:
For Each ele In bag
Dim qty As Integer = CType(gvBag.Rows.Item(cnt).FindControl("txtQty"),
TextBox).Text
If qty > 0 Then
ele.Quantity = qty
Else
bag.Remove(ele)
End If
cnt += 1
Next
This will remove the item from the shopping cart, but then when the Next
loops, the elements have issues because one was removed. Can I reinitialise
the bag arraylist after the remove? I also tried "for i as integer = 0 to
bag.count - 1" but I got the similar issues: after I removed the item, the
total of the bag differed from the original, but the loop kept going....
Thanks,
I have a shopping cart in my arraylist. Works great for adding items but I'm
displaying the shopping cart in a gridview and the user can update the qty
of the items. If they set it to 0, then I want to remove it. I'm doing the
following script:
For Each ele In bag
Dim qty As Integer = CType(gvBag.Rows.Item(cnt).FindControl("txtQty"),
TextBox).Text
If qty > 0 Then
ele.Quantity = qty
Else
bag.Remove(ele)
End If
cnt += 1
Next
This will remove the item from the shopping cart, but then when the Next
loops, the elements have issues because one was removed. Can I reinitialise
the bag arraylist after the remove? I also tried "for i as integer = 0 to
bag.count - 1" but I got the similar issues: after I removed the item, the
total of the bag differed from the original, but the loop kept going....
Thanks,