VB shopping cart datalist ch13
Hi,
Just trying to make the add to cart button to work from the datalist on the wroxshop.aspx - how to I amend the code to point towards the selected row. This is the original code:
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim Price As String = Double.Parse(CType(DataList1.Controls(0).FindContr ol("PriceLabel"), Label).Text)
Dim ProductName As String = CType(DataList1.Controls(0).FindControl("NameLabel "), Label).Text
Dim PictureURL As String = CType(DataList1.Controls(0).FindControl("PictureUr lLabel"), Label).Text
Dim ProductID As Integer = CInt(Request.QueryString("ProductID"))
If Profile.Cart Is Nothing Then
Profile.Cart = New Wrox.Commerce.WroxShoppingCart()
End If
Profile.Cart.Insert(ProductID, Price, 1, ProductName, PictureURL)
Server.Transfer("WroxShop.aspx")
End Sub
I just copied and pasted the code, and it only selects the first item, no matter which button I click. It looks for the Name Label control, but selects only the fist one. How to do I differentiate them?
Any ideas?
Thanks
Alexi
|