Dinamically created textboxes. How to retrieve their content?

fcallery

Newcomer
Joined
Feb 21, 2005
Messages
1
Hi guys.
Mi Asp.Net page creates some textboxes on load depending from records it retrieves from a db. Here is a simplified version (actually I used more control even some of Microsoft.Web.Ui.WebControls assembly):

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not Page.IsPostBack Then
            dbConn.ConnectionString = Application("ConnectionString")
            dbConn.Open()
            Dim cmd As New SqlCommand("select content from textboxes where page = 'home' order by presentation_order", dbConn)
            Dim myReader As SqlDataReader
            myReader = cmd.ExecuteReader()
            While myReader.Read()
                counter = counter + 1
                Dim txtContent As New TextBox()
                txtContent.ID = "txtContent" & counter
                txtContent.TextMode = TextBoxMode.MultiLine
                txtContent.Text = myReader.GetString(0)
                txtContent.Height = a.Percentage(98)
                txtContent.Width = a.Percentage(100)
                MyBase.Controls.Add(txtContent)
            End While
            myReader.Close()
            dbConn.Close()
End Sub

I'd like to know how can I retrieve data from one of the textboxes, and how can I save modified data from all of them into the database. I need to do it by pressing a button, but I don't know how I can.
Please help me.
Thanks a lot.
Fabrizio
 
If you store all the textboxes in an array or collection so you have references to them, then you should be able to access their .Text property, no?
 
Back
Top