views:

169

answers:

4

My problem is that all the textbox's my formview are getting cleared when I hit the submit button.

I currently have a page with a small section that has an update panel around it. This small section adds an address to my databse. To the left of this form there is a gridview that is tied into the formview. So if i click on an item in the gridview its contents fill the address section(formview) with the correct data.

When I hit add the data gets validated in the c# code behind, and if all the info is correct the address is inserted. If there is an error the entire form is cleared and the error message(label) is displayed.

I have already done this many times in other pages, but none have had the gridview tied to the formview, and they have all worked. I tried removing the gridview and the form still erases itself.

Is there some reason that .net thinks it should be clearing the form? When in other cases it decides it won't? If so what are these cases, or what general tips should I try to solve this?

+1  A: 

in the page_load are you using if(!Page.IsPostback) { ... } so if it's a postback nothing gets re-bound?

John Boker
A: 

is the ViewState enabled?

craigmoliver
A: 

Well my page does have a if not post back but that only runs a function that checks for url vars and sets them to session vars. And yes the ViewState is enabled for the formview. Any Other Ideas?

corymathews
A: 

Yup many hours later I found that a single panel that was wrapped around the section had a EnableViewState="false" added to it. Sad part is that I know I didn't add that because I didn't even know what it was until craig here mentioned it. Visual Studio must have added it sometime.

corymathews