SQL Login error when enableviewstate = false

Good day,

I have a view problem in asp.net 2.0.

Basically, I want to disable the viewstate for the gridview. However, when I do this, as soon as there is feedback before getting to Page_Load, I get "Login failed for user sa ...".

If I turn on reverse view mode everything runs smoothly.

In PageLoad, I am setting connection strings to all SqlDataSource, but as I said, the error occurs even before PageLoad.

In PageLoad I tried to do something like: MyGridView.DataSourceId = "MySqlDataSource" but no luck. I'm running out of ideas.

Any idea?

Thank!

0


source to share


1 answer


You must do this earlier in the page lifecycle.

If you are developing an ASP.NET website and you don't understand the page lifecycle, run, DO NOT PASS and read the following:



http://msdn.microsoft.com/en-us/library/ms178472.aspx

Try to set the datasource during the Page_Init event.

+1


source







All Articles