hello everyone i struggling to pass two parameter to an event handler basically when the page is load it dynamically create some control lable, textfield, and linkbutton when i click on the link button it fire an event handler, here is my problem i want to pass first the Product ID and quantity, the product id is fetch from the database passit thorugh an object where as the quantity it enter by the user
first part of the code it connect to database loop through and display all record on the page dynamcally
Function test()
Dim objTemlDall As New Dallyarer
arr = objTemlDall.getRecord()
Dim lblname As Label
Dim lblDes As Label
Dim lblPrice As Label
Dim linkItem As LinkButton
Dim objTemProduct As Product
For Each objTemProduct In arr
lblname = New Label
lblDes = New Label
lblPrice = New Label
linkItem = New LinkButton
txtQuantity = New TextBox
PrdName.Controls.Add(New LiteralControl("<br />"))
lblname.Text = objTemProduct.Name
PrdName.Controls.Add(lblname)
PrdName.Controls.Add(New LiteralControl("<br />"))
PrdDesc.Controls.Add(New LiteralControl("<br />"))
lblDes.Text = objTemProduct.ShortDescription
PrdDesc.Controls.Add(lblDes)
PrdDesc.Controls.Add(New LiteralControl("<br />"))
PrdPrice.Controls.Add(New LiteralControl("<br />"))
lblPrice.Text = objTemProduct.UnitPrice
PrdPrice.Controls.Add(lblPrice)
PrdPrice.Controls.Add(New LiteralControl("<br />"))
PrdQuantity.Controls.Add(New LiteralControl("<br />"))
txtQuantity.ID = "qty"
PrdQuantity.Controls.Add(txtQuantity)
PrdQuantity.Controls.Add(New LiteralControl("<br />"))
开发者_StackOverflow社区 linkItem.Text = "Add to Cart"
linkItem.ID = objTemProduct.ProductID
linkItem.CommandArgument = objTemProduct.ProductID
PrdAddToCart.Controls.Add(New LiteralControl("<br />"))
PrdAddToCart.Controls.Add(linkItem)
PrdAddToCart.Controls.Add(New LiteralControl("<br />"))
AddHandler linkItem.Click, AddressOf GetSelectedProduct
Next objTemProduct
End Function
second part when it fire event handler i want to pass txtQuantity data to GetSelectedProduct event handler how can i achieve that please
Function GetSelectedProduct(ByVal sender As Object, ByVal e As EventArgs)
SelectedProduct = New Product
Dim lbLink As LinkButton = CType(sender, LinkButton)
SelectedProduct.ProductID = lbLink.CommandArgument
Dim objTemlCart As New Dallyarer
arr = objTemlCart.getRecord()
Dim objT As Product
For Each objT In arr
If objT.ProductID = SelectedProduct.ProductID Then
SelectedProduct.ProductID = objT.ProductID
SelectedProduct.Name = objT.Name
SelectedProduct.UnitPrice = objT.UnitPrice
End If
Next objT
If Page.IsValid Then
Dim CartItem As New CartItem
CartItem.Product = SelectedProduct
'CartItem.Quantity = CType(Me.txtQuantity.Text, Integer)
Me.AddToCart(CartItem)
End If
End Function
thank you
Try this:
object.addEventListener(FlexEvent.MouseEvent, function
(e:MouseEvent) : void {
doSomething(param1, param2);
});
Send an Object that has those to parameters as it's properties.
精彩评论