Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

SqlDataSource databinding a listbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mohaaron@gmail.com - 30 Oct 2007 01:07 GMT
Hello all,

This probably applies to controls other then the listbox but it's what
I'm having my problem with now. Can anyone tell me if the databinding
event is called late in the cycle or not. I ask because when I use a
declaritive SqlDataSource control with my list box I am checking the
listbox.Items.Count in the page load event and it's always zero.

I wanted to do a foreach ListItem in listbox.Items but it's empty.

Thanks
Eliyahu Goldin - 30 Oct 2007 09:17 GMT
Put the foreach loop in the PreRender event for either listbox or the page.
In PreRender event controls are already fully built.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> Hello all,
>
[quoted text clipped - 7 lines]
>
> Thanks
Masudur - 30 Oct 2007 12:40 GMT
On Oct 30, 6:07 am, "mohaa...@gmail.com" <mohaa...@gmail.com> wrote:
> Hello all,
>
[quoted text clipped - 7 lines]
>
> Thanks
Hi,

Try Perform your operation onRender method..

Thanks
Masudur
Dave Bush - 30 Oct 2007 13:01 GMT
Page_Load is one of the first events that fires.  You want to get the
count during the DataBound event of the ListBox

-----Original Message-----
From: mohaaron@gmail.com [mailto:mohaaron@gmail.com]
Posted At: Monday, October 29, 2007 8:07 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: SqlDataSource databinding a listbox
Subject: SqlDataSource databinding a listbox

Hello all,

This probably applies to controls other then the listbox but it's what
I'm having my problem with now. Can anyone tell me if the databinding
event is called late in the cycle or not. I ask because when I use a
declaritive SqlDataSource control with my list box I am checking the
listbox.Items.Count in the page load event and it's always zero.

I wanted to do a foreach ListItem in listbox.Items but it's empty.

Thanks
mohaaron@gmail.com - 30 Oct 2007 17:27 GMT
OK, I manage to find another way to make this work. If I call the
listbox.Databind() method it binding happens earlier so I now do this
before I want to do the foreach loop.

Thanks for all your answers. Knowing that I can also do this on the
PreRender event is good also.

> Page_Load is one of the first events that fires.  You want to get the
> count during the DataBound event of the ListBox
[quoted text clipped - 20 lines]
>
> - Show quoted text -

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.