大家好我努力将两个参数传递给事件处理程序基本上当页面加载时它动态创建一些控制标签,文本字段和链接按钮当我点击链接按钮时它会激活一个事件处理程序,这是我的问题我想要先传递产品ID和数量,产品ID是从数据库passit中获取的一个对象,用户输入的数量
它连接到数据库的代码的第一部分循环并在动态页面上显示所有记录
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 />"))
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
第二部分当它触发事件处理程序时我想将txtQuantity数据传递给GetSelectedProduct事件处理程序我该如何实现呢
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
谢谢
答案 0 :(得分:0)
试试这个:
object.addEventListener(FlexEvent.MouseEvent, function
(e:MouseEvent) : void {
doSomething(param1, param2);
});
答案 1 :(得分:0)
发送一个包含参数的对象作为其属性。