SqlDataSource.Selecting before Page_Load on postback?

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...
 
M

Milosz Skalecki [MCAD]

Seems like the control referencing SqlDataSource has ViewState switched off.
It is correct?
 
D

David W

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top