Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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
 
Old April 9th, 2006, 03:07 PM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default SqlDataSource Page Positioning

Hi All

Its only just occurred to me and may not be anything but thought I would ask anyway...

I have a page that has 6 separate SqlDataSources which I have positioned at the top of the page as the first thing within the <form> tag.

No the questions are...

1. does this mean that when accessing this page that 6 separate instances of a DB connection is open even though their relevant item templates may not be being used (edititemtemplate, insertitemtemplate etc)?

2. Would it increase page performance if I was to nest the SqlDataSources within their relevant items templates?

Many thanks for your wisdom.

Rit
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
 
Old April 11th, 2006, 12:59 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Rit,

AFAIK, it doesn't really matter. The DataSource controls aren't triggered until they are necessary.

You can very easily see for yourself how this works by creating a sample page:

1. Add a GridView

2. Bind the GridView to a new SqlDataSource and enable Editing on the GridView.

3. Customize one column of the grid (make it an item template)

4. Customize the EditItem template. Remove the text box and add a DropDownList control. Bind it to a new and embedded (inside the ItemTemplate) DataSource control and set its DataBindings.

5. Selected the embedded DataSource control, and hook up a handler for its Selecting event (that fires when it's about to access the database)

6. Repeat this for the "outer" DataSource.

7. Set breakpoints on both handlers in the code behind.

8. Run the page.

You'll see that only the outer Selecting event is triggered. As soon as you click Edit the inner Selecting event is now triggered to get data for the DropDownList.

9. Next, cut the inner DataSource from the template and past it below the outer DataSOurce control. Run the page again.

You'll see the exact same behavior. The "inner" DataSource control doesn't access the data, until it's required by another control.

Maybe there are circumstances where the above isn't true, but this is how I have always seen the DataSource controls operate.

Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
 
Old April 11th, 2006, 03:22 PM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

Thanks Imar, Just one of those thoughts :-).

By the way, your new book arrived at my doorstep on Friday... man, straight away it was being used!... I love the book’s ‘practical’ approach... Its ideal for developers jumping in the deep end with projects.

One of the best things about the book is actually seeing methods/ controls being implemented which a lot of programming books provide the theory but not so much real situation practice where this book is a complete switch around.

I recommend it to anyone in a similar situation to me! – My theory is and always will be ‘Jump and the net to catch me will appear’.

http://www.wrox.com/WileyCDA/WroxTit...471749516.html
ISBN: 0-471-74951-6

Rit

Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
 
Old April 11th, 2006, 03:47 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Spread the word, spread the word!!! ;)

I am very interested in how you like the book so if you want to contact me to discuss your findings (either here or off-list through my Profile page), please do.

Cheers and have fun,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
While typing this post, I was listening to: Tonight, Tonight by The Smashing Pumpkins (Track 2 from the album: Mellon Collie and the Infinite Sadness - Dawn to Dusk) What's This?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Positioning zach_1988 XSLT 4 December 1st, 2008 07:45 PM
positioning issue Adam H-W CSS Cascading Style Sheets 3 January 20th, 2007 07:28 AM
Positioning Problem harpua CSS Cascading Style Sheets 5 May 27th, 2005 08:03 AM
fixed positioning mackknife BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 May 8th, 2005 10:37 AM
cursor positioning alihussein3 Javascript How-To 1 October 22nd, 2003 03:52 AM





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