By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,963 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,963 IT Pros & Developers. It's quick & easy.

ObjectDataSource_Load and Page_Load events - What Order?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.