Determining item count of databound DropDownList

K

Kyle K.

Environment: ASP.NET 2 on WinXP SP2 w/ VS2005

I have a Databound DropDownList control on a templated page that I would
like to conditionally display as determined by the # of items in the
control.

Using a MultiView control...
Count = 0, display a message (view1)
Count > 0, display DropDownList & Button (view2)

I need the ability to programatically set which view is displayed AFTER
the DropDownList has loaded the data from the database.

I tried placing the code to do this inside the Page_Load() &
(controlName)_DataBound() events, but the Page_Load() event is called
before the data is bound and the (controlName)_DataBound() event doesn't
get called at all (breakpoint not reached when debugging the page).

Not sure if it matters or not, but I am using an ObjectDataSource that
references a DataSet (.xsd).

What method should I use in order to determine which view is displayed
at runtime?

-={ Kyle K }=-
 
K

Kyle K.

I figured it out (while checking out solution #1 below)...

If the View that contains the DropDownList is not active when the page
is loaded, then the DataBound event won't get fired.

I had left the MultiView's ActiveViewIndex = -1 (default), meaning none
of the views get displayed. I figured that I'd just choose the one to
display at run-time. Once I switched this to show the view that
contained the DropDownList by default, then the DataBound event fired.

Thanks for the help!

-={ Kyle K }=-
 

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,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top