我在asp.net页面的页面加载时以编程方式创建按钮,并尝试连接他们的点击而没有任何运气。我需要的是生成按钮,然后将他们的点击发送到一个子(之前的子被非生成按钮预处理)并将他们的AsyncPostBackTrigger连接起来。在我开始尝试在加载时生成按钮之前,这一切都有效。
Dim supplierButton As Button
selectButtonsPanel.Controls.Clear()
For Each row As DataRow In supplierDataTable.Rows
If bizClass.dbCStr(row.Item(0)) <> "Stock" Then
supplierButton = New Button
supplierButton.Text = "Select " & row.Item(0).ToString
supplierButton.ID = "select" & row.Item(0).ToString & "Button"
AddHandler supplierButton.Click, AddressOf selectButton_Click
Dim trig As New AsyncPostBackTrigger
trig.ControlID = supplierButton.UniqueID
trig.EventName = "Click"
UpdatePanel1.Triggers.Add(trig)
selectButtonsPanel.Controls.Add(supplierButton)
End If
Next row