G
Gary Vidal
I have a shopping cart webpage that shows a product and the Quantity they
would like to order:
When you click the link I want to take the quantity that they entered in the
textbox and post that to the next page. But it keeps the original quantity I
added to the viewstate.
Where can i code this to post the correct quantity.
Here is the code-behind I use.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
' Obtain ProductID from QueryString
Dim ProductID As Integer = CInt(Request.Params("ProductID"))
myProductID = ProductID
' Obtain Product Details
Dim products As IBuySpy.ProductsDB = New IBuySpy.ProductsDB
Dim myProductDetails As IBuySpy.ProductDetails =
products.GetProductDetails(ProductID)
' Update Controls with Product Details
desc.Text = myProductDetails.Description
UnitCost.Text = String.Format("{0:c}", myProductDetails.UnitCost)
'ModelName.Text = myProductDetails.ModelNumber
ModelNumber.Text = myProductDetails.ModelNumber.ToString()
NumericCode.Text = myProductDetails.NumericCode.ToString()
UnitOfMeasure.Text = myProductDetails.UnitofMeasure.ToString()
MinQuantity.Text = myProductDetails.MinQuantity.ToString()
MinQuantity_Hidden.Text = myProductDetails.MinQuantity.ToString()
OrderQuantity.Text = myProductDetails.MinQuantity.ToString()
If myProductDetails.Available = "Y" Then
Available.Text = "Product is Available"
OrderQuantity.Enabled = True
Else
Available.Text = "Product is not available"
OrderQuantity.Enabled = False
End If
ProductImage.ImageUrl = "Images/webimages/" & myProductDetails.ProductImage
& ".gif"
'addToCart.NavigateUrl = "AddToCart.aspx?ProductID=" & ProductID &
"&Referer=" & Me.Request.UrlReferrer.ToString
ReviewList.ProductID = ProductID
AlsoBoughtList.ProductID = ProductID
ViewState("ProductID") = CInt(Request.Params("ProductID"))
ViewState("OrderQuantity") = myProductDetails.MinQuantity.ToString()
ViewState("ReferrerUrl") = Request.UrlReferrer.ToString()
Else
OrderQuantity.Text = ViewState.Item("OrderQuantity")
End If
End Sub
Private Sub AddToCart_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles AddToCart.Click
Response.Redirect("AddToCart.aspx?ProductID=" & ViewState.Item("ProductID")
& "&Quantity=" & ViewState.Item("OrderQuantity") & "&ReturnURL=" &
ViewState("ReferrerUrl"))
End Sub
End Class
would like to order:
When you click the link I want to take the quantity that they entered in the
textbox and post that to the next page. But it keeps the original quantity I
added to the viewstate.
Where can i code this to post the correct quantity.
Here is the code-behind I use.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
' Obtain ProductID from QueryString
Dim ProductID As Integer = CInt(Request.Params("ProductID"))
myProductID = ProductID
' Obtain Product Details
Dim products As IBuySpy.ProductsDB = New IBuySpy.ProductsDB
Dim myProductDetails As IBuySpy.ProductDetails =
products.GetProductDetails(ProductID)
' Update Controls with Product Details
desc.Text = myProductDetails.Description
UnitCost.Text = String.Format("{0:c}", myProductDetails.UnitCost)
'ModelName.Text = myProductDetails.ModelNumber
ModelNumber.Text = myProductDetails.ModelNumber.ToString()
NumericCode.Text = myProductDetails.NumericCode.ToString()
UnitOfMeasure.Text = myProductDetails.UnitofMeasure.ToString()
MinQuantity.Text = myProductDetails.MinQuantity.ToString()
MinQuantity_Hidden.Text = myProductDetails.MinQuantity.ToString()
OrderQuantity.Text = myProductDetails.MinQuantity.ToString()
If myProductDetails.Available = "Y" Then
Available.Text = "Product is Available"
OrderQuantity.Enabled = True
Else
Available.Text = "Product is not available"
OrderQuantity.Enabled = False
End If
ProductImage.ImageUrl = "Images/webimages/" & myProductDetails.ProductImage
& ".gif"
'addToCart.NavigateUrl = "AddToCart.aspx?ProductID=" & ProductID &
"&Referer=" & Me.Request.UrlReferrer.ToString
ReviewList.ProductID = ProductID
AlsoBoughtList.ProductID = ProductID
ViewState("ProductID") = CInt(Request.Params("ProductID"))
ViewState("OrderQuantity") = myProductDetails.MinQuantity.ToString()
ViewState("ReferrerUrl") = Request.UrlReferrer.ToString()
Else
OrderQuantity.Text = ViewState.Item("OrderQuantity")
End If
End Sub
Private Sub AddToCart_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles AddToCart.Click
Response.Redirect("AddToCart.aspx?ProductID=" & ViewState.Item("ProductID")
& "&Quantity=" & ViewState.Item("OrderQuantity") & "&ReturnURL=" &
ViewState("ReferrerUrl"))
End Sub
End Class