SqlDataSource.Selecting before Page_Load on postback?

  • Thread starter Thread starter David W
  • Start date Start date
D

David W

I have a pretty simple page with a GridView, a DropDownList as a filter to
the GridView, and a filter Button. Both gridview and dropdownlist are bound
to SqlDataSources. I am setting another parameter in the Selecting event of
the datasource, but the strange thing is the order of the events that fire.

When I first enter the page the event order is:

Page_Init
Page_Load
SqlDataSource.Selecting

But when I press the filter button and get a postback, the event order
changes to:

Page_Init
SqlDataSource.Selecting
Page_Load

Why would this happen? There are things that have to happen in the
Page_Load before the Selecting event happens. Its very disturbing that I
can't count on the life cycle of the page to be consistant...
 
Seems like the control referencing SqlDataSource has ViewState switched off.
It is correct?
 
The page has viewstate turned off, the control doesn't explicitly have it
off. Why would this affect the order of the events? How do I fix this
without turning viewstate on?
 
Back
Top