Dynamic Textbox Array

  • Thread starter Thread starter Eric Diana
  • Start date Start date
E

Eric Diana

Hello,

Im trying to create a dynamic array of textboxes from an array
returned by a web service. THe web service returns a list of fields
that I need to place on a dynamically created web page. The problem I
am having is when the button event is clicked, the text typed in the
textbox doesn't get saved with the textbox. I might be way off base
with even trying this. If anyone could give me some idea on what is
going wrong or another way to produce the form, I would greatly
appreciate it.

Here is the following code for the page I am producing

Try
If Not Me.IsPostBack Then
Result = FieldList.GetFieldListing(FEID, ClientID, UserName,
Password, Fields, ErrMsg)
If Not Result Is Nothing Then
For j = 0 To UBound(Result)
txtBox = New System.Web.UI.WebControls.TextBox
txtLabels = New System.Web.UI.WebControls.Label
txtLabels.ID = Result(j) & "lbl"
txtBox.ID = j
txtLabels.Enabled = True
txtLabels.EnableViewState = True
txtLabels.Font.Size = txtLabels.Font.Size.XSmall

txtLabels.Style("Position") = "Absolute"
txtLabels.Style("Top") = CStr(4 + k) & "px"
txtLabels.Style("Left") = "0px"
txtLabels.Style("Width") = "50px"
txtLabels.Text = Result(j)
txtBox.Attributes("AutoPostBack") = "True"
'txtBoxes(j).AutoPostBack = True
txtBox.Text = txtBox.ID.ToString
txtBox.ReadOnly = False
txtBox.Enabled = True
txtBox.TextMode = TextBoxMode.SingleLine
txtBox.EnableViewState = True
txtBox.Wrap = True
txtBox.Style("BorderStyle") = "NotSet"
txtBox.Style("Position") = "Absolute"
txtBox.Style("Top") = CStr(k) & "px"
txtBox.Style("Left") = "140px"
txtBox.Style("Width") = "200px"
k = k + 25
PlaceHolder1.Controls.Add(txtBox)
PlaceHolder1.Controls.Add(txtLabels)
Panel1.Controls.Add(txtBox)
Panel1.Controls.Add(txtLabels)
Panel1.Style("Height") = CStr(k) & "px"
Panel1.Style("Width") = "341px"
Panel1.Style("Top") = "5px"
Panel1.Style("Left") = "5px"
btnSearch.Style("Top") = CStr(k + 25) & "px"
btnSearch.Style("Left") = "5px"
'WebForm.Controls.Add(txtBoxes(j))
Next j
k = 0
End If
End If
Catch ErrorMessage As Exception
TextBox1.Text = ErrorMessage.Message() & ErrorMessage.Source
Finally
End Try
 
Hi Eric,

Why not first trying with one very simple textbox without any condition and
then build it up in the complete style you are busy with?

I think with what you doing now is getting every time more way off base.

As a first idea of my, you need of course somewhere to have a postback
situation also or in a button event, a setted click event or in your
loadpage in the IsPostback situation..

Just a thought

Cor
 
Back
Top