kleine Posted April 26, 2005 Posted April 26, 2005 Hi, The following code generates a (html)tabel with three cells and an ammount of columns wihich is specified in a textbox that should be filled in by a user (the user gives the ammount of collumns clicks a "button" and the collumn with the desired ammoun of rows is "drawn". Dim i As Integer For i = 1 To CType(txtAmountDelivered.Text, Integer) Dim row As New HtmlTableRow Dim ddlArt As New DropDownList 'items come later out of a db ddlArt.Items.Add("artikel1") ddlArt.Items.Add("artikel2") ddlArt.Items.Add("artikel3") ddlArt.Items.Add("artikel4") 'etc... Dim txttest As New TextBox txttest.Font.Name = "verdana" txttest.Font.Size = txttest.Font.Size.XXSmall txttest.Text = "Amount" Dim cel1 As New HtmlTableCell Dim cel2 As New HtmlTableCell Dim cel3 As New HtmlTableCell Dim lblArtOmschrijving As New Label lblArtdescription.Text = "--from afas DB--" 'changes later depending on what is chosen out of the dropdowlist (which is generated) 'cel1.InnerText = "test" 'cel2.InnerText = "test" 'cel3.Controls.Add(txttest) cel1.Controls.Add(ddlArt) cel2.Controls.Add(lblArtOmschrijving) cel3.Controls.Add(txttest) row.Cells.Add(cel1) row.Cells.Add(cel2) row.Cells.Add(cel3) tbl_Delivered.Rows.Add(row) next This works perfectly but: cell1 contains a dropdownlist with values coming out of an sqlDB My question: How can I acces the generated controls (dropdownlists) if they don't even "exist" the first time the app. is runned. so: how can I fire the selectedIndexChanged event from the generated controls thanx in advance K. Quote
Moderators Robby Posted April 27, 2005 Moderators Posted April 27, 2005 Let's say the DDL is in a Panel, use panel1.findcontrol() to locate the child control. Something like this... dim dd as Dropdownlist dd = CType(panel1.FindControl("myDD"), DropDownList) if not dd is nothing then 'do something with the dd here end if Quote Visit...Bassic Software
kleine Posted June 7, 2005 Author Posted June 7, 2005 Tnx for the help Robby, but could you please give me a more code based example which creates a button at runtime + the (on-click) eventhandler for the generated controll. Thanks in advance, hope hearing from you soon. greets K. Quote
Moderators Robby Posted June 7, 2005 Moderators Posted June 7, 2005 To create a button at runtime: Dim btn as button for x as integer = 0 to 5 btn = new buton btn.text = "Hello " & x panel1.controls.add(btn) next Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.