I'm using three DropDown controls in cascade, and a CommandButton to fill a gridview. When the last control fills up, and I press my CommandButton, I can't see the value of the last DropDown. I mean that the value arrives empty, but the other two have the right value.
One thing that I've noted is that this happend when the DropDown is populated with only one item.
Any help or guidance would be apreciated.Debugging a little more I've foud that the problem is the item marked as default in the DropDown. If I select the items manually, it works fine, but when I left untouched the dinamically populated DropDown's (with the items marked as default shown in them), then I recive an empty string as value.
Anyone has had this problem?
Regards
Thanks for the report. I've opened work item 2218 to track this. I believe I have a fix you can try.
In CascadingDropDownBehavior.js, change:
       // if we didn't match the selected value, and we found a default
        // item, select that one.
        //
        if (!matchedSelectedValue && defaultIndex != -1) {
            e.options[defaultIndex].selected = true;
            this.set_SelectedValue(e.options[defaultIndex].value);
       }
        if(!inInit && !matchedSelectedValue && !gettingList) {
            this.set_SelectedValue('');
        }
To:
        // if we didn't match the selected value, and we found a default
        // item, select that one.
        //
        if (!matchedSelectedValue && defaultIndex != -1) {
            e.options[defaultIndex].selected = true;
            this.set_SelectedValue(e.options[defaultIndex].value);
       } else if (!inInit && !matchedSelectedValue && !gettingList) {
            this.set_SelectedValue('');
        }
That fixes the problem for me in my simple scenario. Please let me know if it works for you, too.
I didn't realize it was so easy to change! Thank you a lot, now it works as expected.
I've fixed this for the next release of the Toolkit as change 3778 in CodePlex:
CascadingDropDown's handling of default values for drop-downs that the user didn't interact with was such that an empty value would be seen on the server for the relevant .SelectedValue on postback. Fix that problem and add an automated test case to cover the scenario.
 
No comments:
Post a Comment