Beh, non so se questo è il modo corretto .... ma funziona!
1 // set default value
2 function setSelectedIndex(_control, _value) {
3 for ( var i = 0; i < _control.options.length; i++ ) {
4 if ( _control.options[i].value == _value ) {
5 _control.options[i].selected = true;
6 return;
7 }
8 }
9 }
10 // Load Data From DB
11 function LoadData()
12 {
13 GetWebServiceProxy().GetDataFromDB(key, LoadSuccess, LoadFail, key);
14 }
15 // Binding Data
16 function LoadSuccess(result, userContext, methodName)
17 {
18 // set the Parent value
19 setSelectedIndex( $get(ddlParent), result.parentValue );
20 // set the Child value
21 $find("bIDChild").set_contextKey( result.parentValue );
22 $find("bIDChild")._onParentChange( null, false );
23 $find("bIDChild").set_SelectedValue( result.childValue, result.childValue );
24 }
25
26 // Raise Error
27 function LoadFail(result, userContext, methodName)
28 {
29 alert('[LoadData] method fail.');
30 }
31 </script>
32
33 <div>
34 <asp:DropDownList ID="ddlParent" runat="server">
35 </asp:DropDownList>
36 <ajaxToolkit:CascadingDropDown ID="cdParent" runat="server" TargetControlID="ddlParent"
37 Category="Parent" PromptText="Please select an Parent" LoadingText="[Loading Parent...]"
38 ServicePath="myWebServices.asmx" ServiceMethod="myWebMethod" BehaviorID="bIDParent" />
39 <asp:DropDownList ID="ddlChild" runat="server">
40 </asp:DropDownList>
41 <ajaxToolkit:CascadingDropDown ID="cdChild" runat="server" TargetControlID="ddlChild"
42 Category="Child" PromptText="Please select an Child" LoadingText="[Loading Child...]"
43 ServicePath="myWebServices.asmx" ServiceMethod="myWebMethod" BehaviorID="bIDChild"
44 ParentControlID="ddlParent" />
45 </div>