Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 September 14th, 2011, 03:45 AM
Registered User
 
Join Date: Sep 2011
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
Default DropDownList databind()

Hi,

I have noticed that if i want to make a pre-selection in the dropdownlist at the page_load function i have to first call the DDL.databind() because there are no Items until then,. my question is why there are items in the dropdownlist even if i didn't call the databind() function (the list is using a sqldatasource).
my question is referenced to the Genre list in the Reviews.aspx file, that when i wanted to make it pre-selected i had to use the databind() fun, but before i wanted to do that, there was no databind() on the dropdownlist, but still the list shows the genre items on it when you load the page.

Thanks, Roni.
 
Old September 14th, 2011, 03:49 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It's because DataBind is called automatically by the page control at a later stage. For more details about the page life cycle and databinding, take a look here: http://msdn.microsoft.com/en-us/library/ms178472.aspx

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 14th, 2011, 03:56 AM
Registered User
 
Join Date: Sep 2011
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Oh, I see,. It was a little confusing, will go read more about the page life cycle.

Thanks alot Imar! :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Databind DarkForce ASP.NET 2.0 Basics 5 January 25th, 2011 12:04 PM
About the Databind() kuuy BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 1 November 15th, 2006 12:56 PM
Databind in TextBox kapi.goel C# 1 April 26th, 2006 05:51 AM
Can't get RadioButtonlist with databind nayalksrs123 .NET Web Services 0 January 15th, 2005 06:29 AM
DataBind Problem liorlankri ADO.NET 3 November 2nd, 2004 04:13 PM





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