473,471 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

asp.net textbox text not updating

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?

Nov 19 '05 #1
1 4274
The following information is from the MSDN documentation and explains the
issue you are seeing. It relates to the page ViewState. Please see the
MSDN documentation on ViewState for more information.

From MSDN documentation:

If you reinsert controls with each round trip, each generation of
dynamically created controls will pick up property values from the view
state of the preceding set of controls. In many cases, you can avoid this
problem by setting the EnableViewState property of the container control to
false. In that case, no information about the dynamic controls is saved, and
there is no conflict with successive versions of the controls.
--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
<se*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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?

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: trint | last post by:
I have a textbox (textBox7) that isn't updating.. Is there a way, after I type new text in it, to have it update? It seems to be fairly normal: public class Form1 : System.Windows.Forms.Form {...
28
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I...
7
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
22
by: Tim | last post by:
Hi A while ago I got some help in writing a mock console. The idea was to write a VB app that contained a textbox, then run a process from within the app and redirect the stdout to the textbox. ...
0
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
9
by: Phill W. | last post by:
VB.Net 2005 SP1 Windows Forms Application What's the fastest way to append text to a TextBox? I have an application that monitors data written to text files. It needs to scan some fairly...
0
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. ...
3
by: Avi | last post by:
Hi all, I have a web page with Multiline TextBox. Every 3 seconds I refresh the page and display all received messages in this TextBox. When the TextBox is updated (The Text property is set). ...
2
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.