I used the dropdown extender a lot and noticed now a strange behavior, that makes it kind of a showstopper, if there is no workaround:
I have three DropDownLists exactly like in the example of the Toolkit. Except for the first DropDownList all values are filled in via the DropDownExtender. I did not use the optional PromptText property, because I do want to have the first value in each DropDownList preselected. This looks OK, so if I change the value of the first DropDownExtender, the values update in a cascade and the first item of each dropdown seems to be preselected - perfect. But if a postback happens now, the actual DropDownLists are empty and no value is selected, they are only selected, if the user would go on and open the drop down list and really select a value only then the values are also visible on the server side.
Is there any method I could call on the extender or on the dropdownlist to make the values visible on the server after a postback without having the user to click on the combobox and select the same value he already sees? That would be kind of hard to explain...
The behavior is easily to reproduce with the example from the Toolkit, just change in CascadingDropDown.aspx
<table> <tr> <td>Make</td> <td><asp:DropDownList ID="DropDownList1" runat="server" Width="170" /></td> </tr> <tr> <td>Model</td> <td><asp:DropDownList ID="DropDownList2" runat="server" Width="170" /></td> </tr> <tr> <td>Color</td> <td><asp:DropDownList ID="DropDownList3" runat="server" Width="170" AutoPostBack="true" /></td> </tr> </table> <asp:Button ID="Button1" runat="server" Text="Button" UseSubmitBehavior="false" OnClick="DropDownList3_SelectedIndexChanged" /> <br /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1" Category="Make" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents" /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server" TargetControlID="DropDownList2" Category="Model" ServiceMethod="GetDropDownContentsPageMethod" ParentControlID="DropDownList1" /> <ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="DropDownList3" Category="Color" ServicePath="~/CascadingDropDown/CarsService.asmx" ServiceMethod="GetDropDownContents" ParentControlID="DropDownList2" />
ups... always learning... there is a "isDefault" flag on the CascadingDropDownValue collection, that just has to be set... problem solved!
No comments:
Post a Comment