databound textbox does not refresh

jayreed21

Newcomer
Joined
Feb 12, 2007
Messages
5
I am creating a website in c# asp.net. I have a databound text box that is supposed to refresh according to a variable which gets changed. The textbox will change to the correct value when a link is clicked passing the variable, however when the variable is changed in a dropdown list all of the information on the change updates except for the text box. Is there some kind of refresh or something that I need to do? I do not understand why it changes with a link but not with a dropdown selection.
 
What do you mean by "all of the information"? Do you have other controls that is bound? Can you give a more detail description of your problem? Such as what is your text box bound to, what is the link that is clicked, what is the behavior of your dropdownlist, etc. I believe you know that binding mechanism in windows application and in web application is similar but not identical.
 
Yes there are other labels that get updated from a specific variable. The textbox is supopsed to get updated as well and does when the variable is changed in the url from a dynamic link, but when the same variable is changed from a drop down, then all the other labels get updated except for the textbox.
Its like the textbox will not refresh unless refreshed by the url.
 
Are you using a dataset as your general datasource? What method did you use to bind those controls? If you use simple binding, have you called the DataBind() method of each controls? Your dropdownlist triggers a postback right? Have you debug the event handler for your dropdownlist?

I can see your problem exist in updating that textbox. But with your explanation I don't think I can give any specific information. Sorry.
 
The textbox is getting updated by a method call to a database which gets a string. It tuns out that if I drag a textbox onto the screen from the asp toolbox and set the visibility to false, I can add this textbox when needed and it will update correctly. Previously, the textbox was created dynamically as part of the class above the page load.

It makes no sense to me why visual studio treats a textbox created statically in the asp page differently than one create in the aspx.cs file. Is there any known difference between the two. The only property that the text box created from the toolbox has that the one we were creating was the run="server" property.

Weird huh?
 
I'm still guessing here. But I kinda get a grip of your situation.

The runat="server" attribute is necessary so that your textbox can be accessed from codebehind (the "aspx.cs") file. It is a necessary means to communicate between the "aspx" file and the "aspx.cs" file.

When you create your textbox programmatically, it will not generate error when updated since it is a valid object. But doing that means you're only manipulating the textbox without communication with the "aspx" file. That way you won't see the changes when running your application.

I've always generate any widget using the toolbox in the design view. That way I'm certain that any modification to the widget programmatically will be shown correctly on the interface.

Hope that helps.
 
thanks for the replies Amir.. I think you are dead on to my problem now... This does, however bring up an issue. The boxes that we create need to be created dynamically according to how many are needed.. It would be really poor programming for us to just drag 10 or so on the screen and use as necissary.. What if for some reason a user requested 11... There has to be some way around this issue.. The textbox is holding information from the previous page and not refreshing unless a complete redirect occurs.. we even try creating a new one before assinging the new text to it.. we also even response.write the contents of the text box and it shows the correct string on top of the page but not in the box!?

So I guess we will just hack through that part for now, but there has be some kind of resolution for this...

Thanks for your help so far!
 
Which server side event are you using to create the textboxes? If you want the controls to automatically load information from the page that is being posted back you really need to create them controls in (or before) the Page_Load event.
 
hmmm.... so maybee we want to create them in the pageload then. Presently we create them before the page load as part of the class.
 
Back
Top