I am trying to create a click handler on an update quantities button which updates the quantities with the textbox. I am using a datalist and have addressed the "ProductID" as the DataKeyField. Can someone please help me code this?
This is the code
--------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim productID As String = Request.Params("AddToCart" )
If Not productID Is Nothing Then
Dim cart As New ShoppingCart()
cart.AddProduct(productID)
End If
BindShoppingCart()
checkoutCodeLabel.Text = "Checkout Code: "
End If
End Sub
Private Sub BindShoppingCart()
Dim cart As New ShoppingCart()
list.DataSource = cart.GetProducts
list.DataKeyField = "ProductID"
list.DataBind()
If cart.GetTotalAmount = 0 Then
placeOrderButton.Enabled = False
Else
placeOrderButton.Enabled = True
End If
TotalAmount.Text = "Total amount:"
totalAmountLabel.Text = String.Format("{0:c}", cart.GetTotalAmount())
End Sub
Private Sub btnUpdateQuantity_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateQuantity.Click
(WHAT DO I PUT HERE??????????)
End Sub
Thanks in advance!Where you can get the total after you click the update button and page post back? looks like all the code in page_load will not run for they are in "If Not Page.IsPostBack ".
0 comments:
Post a Comment