Saturday, March 31, 2012

Text box values are not being considered?

Currently i m working on a web page that edits the user information. The already stored info. from the database is being displayed in diffrent text boxes so that user can edit it. The problem is that even when user changes the information in the any of the text-boxes & clicks the submit button, then instead of current value of text-boxes the previously assigned value is being considered. Whats the possible cause of this error?

Possibly... your records arent getting updated


bh_84:

Currently i m working on a web page that edits the user information. The already stored info. from the database is being displayed in diffrent text boxes so that user can edit it. The problem is that even when user changes the information in the any of the text-boxes & clicks the submit button, then instead of current value of text-boxes the previously assigned value is being considered. Whats the possible cause of this error?

Are they data bound controls? That could be your problem. Since the page load method will run before the click handler, if those databound controls are populated on every post back, they are likely being overwritten there. You will need to only data bind the text boxes when the page isn't posting back.


No they r simple text box controls. values are being assigned to them using text property & not through data binding but still on submiting, the not the current values but the previous ones are being considered.

Doesn't matter if you are databinding or assigning the values yourself. Probably what is happening is the user changes the value and then hits submit to post back the page. At that point your code is setting the Text property for these text values to whatever the initial value is just like it does when you first load the page and is overwriting whatever change the user made. You are probably always setting the values even on postback so you never get the values the user specifies. In your code you need to only set the values if it is not a postback. So something like:

If (!IsPostBack)

{

// Set all textboxes to initial values here.

}

That is C# so if you're using VB you'll need to do the similar thing in VB. This will make sure that when the page is posted back the textboxes don't get overwritten witih the initial values and have whatever values were entered at the browser.

0 comments:

Post a Comment