We help IT Professionals succeed at work.
Get Started

EnableViewState, how to override ViewState

Hawkeye6352 asked
Last Modified: 2013-01-11
I have an .aspx C# 2010 page.  It does everything I want it to.  Inserts records.  Updates records.  Only problem is.  When I close the form and come back to it, it loads the previous values into my asp:TextBoxes and asp:CheckBoxes.  I understand that if a viewstate is enabled for a data-bound control, the control will not be rebound when the page is reposted.  Instead the control's values will be restored from the view state.  I understand that to prevent this, you should do EnableViewState = false in the page directive, or in the <asp:whatever tag.  Problem is, this doesn't make any difference.  I have also tried to programmatically set the control's EnableViewState = false, and placed it in the Page_init and the Page_Load, with no luck.  How can I override the view state so that my control is populated from the database and not the view state when the form is opened?
Watch Question
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE