470,590 Members | 2,039 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,590 developers. It's quick & easy.

ObjectDataSource_Load and Page_Load events - What Order?

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
Apr 15 '07 #1
1 1709
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
--
Milosz
"Mikey Baby" wrote:
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
Apr 15 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Studio P.M. | last post: by
2 posts views Thread by Rebecca | last post: by
2 posts views Thread by Frank Schumacher | last post: by
14 posts views Thread by V. Jenks | last post: by
2 posts views Thread by Dave | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.