SqlDataSource databinding a listbox

  • Thread starter Thread starter mohaaron
  • Start date Start date
M

mohaaron

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
 
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
Hi,

Try Perform your operation onRender method..

Thanks
Masudur
 
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: (e-mail address removed) [mailto:[email protected]]
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
 
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.
 
Back
Top