Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

textbox.text not being passed after second submit. c#

Status
Not open for further replies.

tekkerguy

Programmer
Nov 16, 2005
196
US
I've got a table with textbox controls that I'm submitting to a database.

On the .net codebehind, I have a function that loops through all rows and cells and collects the controls. It then passes that arraylist to another class method, which checks if a certain field is already int the database. If not, it adds it to the database, then requeries the database to get the new id created for the entry, and appends that to the id of the controls.

for example, if the control is cntr_firstname, and the text michael doesn't exist, it adds it to the datbase, then requeries the database, and appends the the new entry id, to the id of the textbox control, making it 68_cntr_firstname.

After all of this, it then submits the full record, with the new id.

This is necessary due to related tables.

Anyways, because it's changing the textbox id, if I go and resubmit from the page a second time with a new textbox id, the data is gone because the textbox id has changed on the aspx page. how do I reinitialize the page on reload, to restore the old textbox id?

I'll probably need to clarify this... :S
 
Have you tried explicitly setting the value

Code:
string temp = cntr_firstname.Text;
cntr_firstname.ID = "68_cntr_firstname";
68_cntr_firstname.Text = temp;

No idea if this will work but worth a try.

Incidentally, if this doesn't work you might want to try substituting the original textbox with a new one rather than just changing the ID

HTH

Smeat
 
ASP.NET doesn't like you messing around with Id's as it uses them to preserve state. This may or may not be the issue, but it's the first assumption I would make.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top