Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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):

 

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

  • Leaders
Posted
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?
[sIGPIC]e[/sIGPIC]

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