S
sekisho
I'm dynamically adding a column of labels and a column of text boxes to
a panel on a webform, based on data returned from an SQL query, which
the user builds by selecting options from a few dropdowns and hitting
the 'Search' button.
The first column returned is a user name and is added to the panel as a
label, the second is a number and is added to the label as the text
property of a textbox, so the user can update it.
When the webform is first called and 'Search' is clicked it works fine,
but when the dropdown options are changed and 'Search' clicked again,
the labels change to the correct values but the textboxes retain their
previous values. What's even stranger is that I explored the problem by
creating labels instead of textboxes for the second column, and they
updated correctly, as did using buttons, so it seems to be an issue
only with textboxes not updating.
The code I'm using is pretty basic:
For i = 0 to dt.Rows.Count() - 1
Dim newLabel As Label = New Label
newLabel.Text = dt.Rows(i)(1)
newLabel.ID = "Label" & i
Panel1.Controls.Add(newLabel)
Dim newTextBox As TextBox = New TextBox
newTextBox.Text = dt.Rows(i)(2)
newTextBox.ID = "Textbox" & i
Panel1.Controls.Add(newTextbox)
Panel1.Controls.Add(New LiteralControl("<BR>"))
Next
Where dt is the datatable holding the results of my query, there are
three columns, an index value, a person's name and a number.
Does anyone have any idea what is going on?
a panel on a webform, based on data returned from an SQL query, which
the user builds by selecting options from a few dropdowns and hitting
the 'Search' button.
The first column returned is a user name and is added to the panel as a
label, the second is a number and is added to the label as the text
property of a textbox, so the user can update it.
When the webform is first called and 'Search' is clicked it works fine,
but when the dropdown options are changed and 'Search' clicked again,
the labels change to the correct values but the textboxes retain their
previous values. What's even stranger is that I explored the problem by
creating labels instead of textboxes for the second column, and they
updated correctly, as did using buttons, so it seems to be an issue
only with textboxes not updating.
The code I'm using is pretty basic:
For i = 0 to dt.Rows.Count() - 1
Dim newLabel As Label = New Label
newLabel.Text = dt.Rows(i)(1)
newLabel.ID = "Label" & i
Panel1.Controls.Add(newLabel)
Dim newTextBox As TextBox = New TextBox
newTextBox.Text = dt.Rows(i)(2)
newTextBox.ID = "Textbox" & i
Panel1.Controls.Add(newTextbox)
Panel1.Controls.Add(New LiteralControl("<BR>"))
Next
Where dt is the datatable holding the results of my query, there are
three columns, an index value, a person's name and a number.
Does anyone have any idea what is going on?