Theo
Member
Hi all,
Ive got a procedure that generates some buttons. The information needed for the buttons comes out of a database.
The buttons are generated fine, but how can I use the click event from the buttons?
This is what I have so far:
Ive got a procedure that generates some buttons. The information needed for the buttons comes out of a database.
The buttons are generated fine, but how can I use the click event from the buttons?
This is what I have so far:
Code:
Private Sub GetButtons()
Dim cmd As New SqlClient.SqlCommand
Dim da As New SqlClient.SqlDataAdapter
Dim ds As New DataSet
Dim RowCnt As Long
cmd.Connection = myPublics.conn
cmd.CommandText = "SELECT [id], text FROM folders WHERE parent IS NULL"
ds.Clear()
If ds.Tables.Count > 0 Then ds.Tables(0).Columns.Clear()
da.SelectCommand = cmd
da.Fill(ds)
RowCnt = ds.Tables(0).Rows.Count
If RowCnt > 0 Then
Dim i As Long
For i = 1 To RowCnt
Dim btn As New Button
btn.ID = ds.Tables(0).Rows(i - 1)(0).ToString
btn.Text = ds.Tables(0).Rows(i - 1)(1).ToString
btn.Width = Unit.Pixel(175)
btn.Font.Bold = False
pRootControls.Controls.Add(btn)
btn = Nothing
Next
End If
cmd = Nothing
da = Nothing
ds = Nothing
End Sub