Not bad...with one complaint
I've been working on a new project for a few weeks now and have been trying to blend in the Microsoft Ajax 1.0 extensions and controls where appropriate.

One good illustration is the Cascading DropdownList Extender coupled with WebMethods to drive the population of the dropdowns. Because the feature in question has four dependent dropdowns, this seemed like a great place implement this process.

Creating the presentation and the relations between the dropdowns is fairly straight-forward and once I figured out how to get the WebMethods returning the correct data, all was right in the world. Until...

The feature also requires the ability for the user to add/edit/delete an option of the dropdownlist. Oh, goody...another place to use MS Ajax and their nifty ModalPopup extender.

Since I'm trying to handle all of the functions on the page in a "no postback" manner, I created a WebMethod to handle the insert of the new data. That works without any problems, but here's where I ran into my trouble and posted a plaintive plea for help up at the Ajax forums hosted at asp.net.

My problem: there does not seem to be an easy way to "repopulate" the items in the dropdownlist to include this newly entered data and (this would be a bonus) to have that as the selected option in the affected dropdown.

Yes, I know...I can do a postback and it will pick up the new data. As I said, I want this to be a "no postback" process as this add/edit/delete feature will be available for all four dropdown controls and I don't want to have to repaint the screen for, potentially, every change to these lists.

Well, it took a bunch of coding, but I finally figured out how to both refresh the updated dropdownlist(s) and *bonus* set the new entry to be the selected option, and *double-bonus* fire the onchange() to populate the subordinate dropdown(s).

I'm going to clean the code up a bit, and then I will probably publish a brief article with example code so others that may encounter this issue can have a path to start towards a solution.

Feedback

Please post your comments:

Name:
Email (optional):
Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks
 
Protected by Clearscreen.SharpHIPEnter the code you see: