Good day,
I’m having a problem with asp.net 2.0 viewstate.
Basically, I want to disable the viewstate for a gridview. However, when I do so, as soon as there is a post-back, before even getting into Page_Load, I get a ‘Login failed for user sa …’.
If I enable the viewstate back, everything runs smoothly.
In PageLoad, I set the connection strings to all the SqlDataSource, but as I said, the error comes even before the PageLoad.
In PageLoad, I tried to do something like : MyGridView.DataSourceId = ‘MySqlDataSource’ but with no luck. I’m running out of ideas.
Any idea?
Thank you!
You have to do it earlier in the page lifecycle.
If you are developing an ASP.NET website and don’t understand the page lifecycle, RUN, DO NOT WALK, and read this:
http://msdn.microsoft.com/en-us/library/ms178472.aspx
Try setting the data source during the Page_Init event.