Asp.net restores data after postback
Hi everyone, I have the following problem which is really driving me crazy.
After doing any postback, multiple controls won't regroup like
DetailsView with attached ObjectDataSource (ObjectContainerDataSource in my case) LoginView does not show LoggedInTemplate, but LoginStatus shows me that you are logged in.
I'm almost desperate and I like to know if you've had the same problem or something similar in the past and can give me some hint.
Thanks in advance
a source to share
If the binding is done in the Page_Load method, make sure it is inside an if not postback loop.
if (!IsPostBack)
{
//Your code to bind data
}
After each postback, a page load event is fired. Therefore, if the controls are not bound inside the above loop, the binding will be executed every time a postback occurs.
a source to share
Without seeing any of your actual code, I would suggest you look at the EnableViewState settings for the page and individual controls.
This is a good article on managing viewstate .
You should also look for the code in this section on page_page ()
if(!IsPostback)
{
// code to bind some of your controls
}
This code will only be called the first time the page is entered, not on postbacks. If you leave the page and return, then the anchor code will run again.
a source to share