Adding dropdownlist options via Javascript

D

dkehring

Hi,

Using VS.NET 2005...

I created a custom web control based on the CompositeControl class. This
control creates a table with two columns of DropDownList (DDL) objects. The
DDL objects in the first column are populated with values on the server side.
When the user selects an option from the DDL in the first column, I make an
asychronous callback (AJAX) to a web service on the server to get a list of
options for the selected value in the first DDL. The result of this call
returns a string that I split into name/value pairs and use this to populate
the adjacent DDL in the second column via Javascript. When I post back to the
server, I want to be able to get the value selected in the second DDL. On
postback I recreate the DDLs (by overriding CreateChildControls) but the
second DDL does not show the selected value.

To start, I added an event handler for the first DDL's SelectedIndexChanged
event. When I trap this I get the value from the DDL and use this to load the
list of values and populate the second DDL. However, the value coming back
from postback does not "select" the option from the list. I figure that I'm
not doing this at the right time in the page's life cycle but I can't figure
out how to populate the second DDL prior to the selected value being set in
the second DDL (which I assume happens during the LoadPostBackData method of
the control).

Any ideas how to handle this correctly?

Regards,
Dave
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top