Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi!

 

I have a form where I display the contents from a table in a database. For each record in the database i dynamically generate a textbox and a button. The textbox contains the content of the record in the database and my intention is to give the user the possibility to delete the databasereccord by hitting the button.

 

I put the dynamically generated textboxes and buttons in two arraylists, and adds them to a panel like this.

 

Dim tb as New ArrayList()
Dim btns as New ArrayList()
With rdr

           Dim i As Integer = 0
           
           While rdr.Read
               'Adding TextBox
               tb.Add(New TextBox())
               tb(i).text=rdr.item(1).ToString
               Me.Panel1.Controls.add(tb(i))
               

               'Adding Button
               btns.Add(New Button())
               btns(i).text="Delete this record"
               Me.Panel1.Controls.add(btns(i))
            
               i = i + 1

           End While
           .Close()
End With

 

This is a little simplified, but I manage to generate the form as I want it to look.

My problem is how to respond to a click event from the buttons.

I reccon it has to be dynamically generated events for the buttons too, so that I can find which button the user have clicked.

Anybody has a clue about how I can solve that?

 

I'm using VB.NET by the way..

 

--

Tor Inge Schulstad

NORWAY

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...