Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Moderators
Posted

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

Visit...Bassic Software
  • 1 month later...
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...