ObjectDataSource_Load and Page_Load events - What Order?

G

Guest

Greetings

Hopefully, I can be clear and concise on this one, but I'm confused.

I have a page with a ListBox <- ODS <- BusinessObject and a button.

The Parameter Source is 'None'. The Default Value is left blank. Both are
set in the Page_Load (myODS.SelectParameters[0].DefaultValue = 999)

I put Debug statements in the Page_Load, ODS_Load and method of my
BusinessObject.

On the first time through, I get the following order:
Page_Load
ODS_Load
BusinessObject Method fires

Exactly as expected.

However, on the second post of the page (when I press the button) the order
is as follows:
BusinessObject Method fires(with NO PARAMETERS)
Page_Load
ODS_Load
BusinessObject Method fires (this time with Parameters set)

The additional firing of the BO Method is causing lots of problems (not
least of which is the loss of the SelectedItem on the ListBox).

As you can imagine, this took hours to track down.

Other info:
ODS.EnableCaching = False
ListBox.EnableViewState = True

I've played around with my Page_Load for hours. But of course, it doesn't
get hit until AFTER the ODS_Load.

I can code round this issue, but to be honest it just seems plain wrong to
me. Firing my BO method twice like this is something I just don't want.

Any help hugely appreciated.

Regards

M.

MCDBA : MCSD
 
G

Guest

Hi Mikey,

There must be something wrong with your code as ODS should call business
object select method only if value for one of the select parameters changed
between postback. Please also note Objectdatasourece onload event is useless
(it actually doesn’t do anything interesting) because the control (list box
in this case) is responsible for restoring data from its view state , of
course if the object data source state has not changed. have also in mind
data binding for all controls that have DataSourceID set, occurs inside
OnPreRender event and ODS is only used to provide the data in form of
IEnumerable from Select() method. Could you please paste the code so we could
see what you’re doing wrong...

Regards
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top