Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 10th, 2009, 05:51 PM
Authorized User
 
Join Date: Jun 2009
Posts: 32
Thanks: 17
Thanked 0 Times in 0 Posts
Default Author claims ObjectDataSource is bound to data source before Page_Load and not after

Greetings

I’m learning Asp.Net in parallel with reading this book, so I apologize if I’m way off with my questions.


1) Anyways, on page 257 author says the following:

Quote:
User’s location is not retrieved directly from her profile in the precceding code because that would cause a read for each and every row. Instead user's country, state and city are read only once from the profille and saved in local variables. Page_Load cannot be used for this because automatic binding done by the ObjectDataSource hapens earlier, so we have to use the Page_Init event handler
As far as I know ObjectDataSource is bound to data source after Page_Load and not before?! Or am I missing something?



2) Why does author ( on page 256 ) call gvwArticles.DataBind inside dllArticlesPerPage_SelectedIndexChanged, dllCategories_SelectedIndexChanged and gvwArticles_RowCommand.

As far as I know, ObjectDataSource will automatically call gvwArticles.DataBind on each postback?! I checked this by deleting gvwArticles.DataBind inside those methods, and as far as I could tell, everything worked the same! Or am I again missing something?


cheers
  #2 (permalink)  
Old August 11th, 2009, 03:24 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by carewithl View Post
As far as I know ObjectDataSource is bound to data source after Page_Load and not before?! Or am I missing something?
You are missing something. I think you're confusing the Page_Load of a user control with the Page_Load of a page.

Don't forget, this is a user control you are dealing with. This user control will be hosted in a page.

In the host page life cycle, the ODS databinding takes place before the Page_Load of any user controls hosted in that page.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
The Following User Says Thank You to Lee Dumond For This Useful Post:
carewithl (August 13th, 2009)
  #3 (permalink)  
Old August 13th, 2009, 02:20 PM
Authorized User
 
Join Date: Jun 2009
Posts: 32
Thanks: 17
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Lee Dumond View Post
You are missing something. I think you're confusing the Page_Load of a user control with the Page_Load of a page.


In the host page life cycle, the ODS databinding takes place before the Page_Load of any user controls hosted in that page.
Uhm, are you sure about ODS data binding happening before Page_Load? If we add an ObjectDataSource with a Select method that returns an array of strings, a user control (.ascx) with a repeater that binds to the data source, and a page which added this user control, then the order of events is the following:

Code:
  MyObjectDataSource -> Init
UserControl -> Init
Page -> Init
Page -> Load
UserControl -> Load
MyObjectDataSource -> Load
Repeater1 -> DataBinding
MyObjectDataSource -> Selecting
MyObjectDataSource -> SelectMethod
Repeater1 -> DataBound
Thus UserControl.Load happens before MyObjectDataSource performs data binding. I’m probably (again) missing something very obvious?!

BTW - Nevermind my second question. I thought that ODS performs data binding on each postback, which apparently isn’t the case


cheers mate

Last edited by carewithl; August 13th, 2009 at 02:43 PM..


Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieving a value from data bound to a repeater beeyule General .NET 0 September 8th, 2005 11:59 AM
Incorrect Error Message Claims Multiple Users SerranoG Access 3 April 27th, 2005 01:11 PM
Need help with bound data kcrompt2 Classic ASP Professional 0 February 9th, 2005 12:37 AM
Data Bound ComboBox joblot VB How-To 0 May 5th, 2004 12:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.