473,616 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ObjectDataSourc e_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.SelectPa rameters[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.EnableCachi ng = False
ListBox.EnableV iewState = 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 1832
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 Objectdatasoure ce 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.SelectPa rameters[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.EnableCachi ng = False
ListBox.EnableV iewState = 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
2570
by: z. f. | last post by:
Hi, i have a class that is derived from System.Web.UI.Page, and this is the class i use in my application as PageBase. all other page classes are deriverd from my PageBase instead of the original System.Web.UI.Page in order to have common checks in the page base. i make securirty checks in the page base page_load event. if the security fails, i can do whatever i want before the "real" / derived page gets to be executed.
3
2671
by: Studio P.M. | last post by:
Dear colleagues, I kindly ask the C# developers community to help me to REALLY understand the Page_Load event, so to REALLY have it under control. Reason for this question is that I cannot anymore accept passively the behavior of the “Web Form Designer” automatically generated code because of the fact that, in some circumstances (that I can reproduce at will), my code is victim of a Page_Load multiple “firing”. In other words the...
2
1882
by: Rebecca | last post by:
I have a dynamically created command button on a .net page that adds 1 row to a sql server table when clicked. The page_load event load rows from that table for the user to view, but for some reason it is not loading the most recently added record when the page is reloaded from the command button click. When the page is initially loaded it does display all records. It is like it is executing the page_load method before the method to add the...
2
2530
by: Frank Schumacher | last post by:
Hi Folks, I have a problem with the order of events fired by ASP.NET. I found many articles which explaining the lifecycle of a site, but I found none which took the event from a Control on the site into consideration. Here is what I want to do: I have a Button, which starts a new search session. When this session is started, you have several Usercontrols, which can navigate within the search session.
14
13103
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) { //existing session? if (Session == null) { //save local empty order object this._newOrder = Orders.Initialize();
2
2211
by: Dave | last post by:
Hi, this is a follow-up to an earlier question but I really haven't found a definitive answer in my search If I have a Base and Derived webform, I've found that the dervived Page_Load event fires first, then the base Page_Load. Is the only technique to change this sequence is to override the Base.Page_Load and explicitely call the base event when you want to as below: Derived WebForm
2
3126
by: Opa | last post by:
Hi, I have a form with a javacript function that I wish to call before the Page_Load event on the server side. The function is called in the onload of window (ie. window.onload = "myfunction()" Is this possible? If so how, If not is there a workaround ?
1
1467
by: cmay | last post by:
Can someone advise on this issue? We are seeing a page where, on the first load the base page (the class our page inherits from) fires it's PageLoad event first, followed by our Page's PageLoad. On postback we see the reverse order taking place, with the Base Page firing last. Can someone tell me if this is the expected behavior? Are you not
0
8145
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8642
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8294
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8448
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7118
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6097
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4140
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.