views:

346

answers:

1

I am creating a control that loads three related dropdownlists at runtime, and all three bind their data from a database. when the first list changes value, the 2nd one should rebind based on that value, by default selecting the first item. However, as a result, the third list should ALSO rebind based on the selected first value of the 2nd list.

I can't seem to get the lists to bind on load. The 1st list binds manually, so that loads, but the other two are blank.

I created event handlers for selectedindexchanged for the first 2 lists, which cause the descendent to rebind. This works after the page loads, and I change the 1st lists selected item.

However, I can't get the 2nd and 3rd lists to bind on page load. I tried setting the SelectedIndex to be 0, so that the first list selected the first item by default. I THOUGHT this would fire the selectedindexchanged event,

but it doesn't! why doesn't selecting an item on the server side cause the event to be raised? If it did, all my problems would be solved because raising that event would bind the second list, selecting the first item, which would raise ITS changed event, rebinding the third list.

but none of this happens because the first list won't fire the event.

so what is the correct way to do this?

thanks!

A: 

If you can set the selectedindex for the first one, you can call the method directly instead of fire an event. event is nothing but a method call.

same for the second one and third one.

Henry Gao
that's exactly what i did. it didn't work, so I posted here.then it worked. so I guess it was just waiting for me to give up to work. oh well! thanks anyway!
Josh