SqlDataSource databinding a listbox

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
 
M

Masudur

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
 
D

Dave Bush

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
 
M

mohaaron

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top