我更新了 Ajax 控制工具包。并且 CascadingDropDown 始终从 Web 方法设置默认值(在任何回发事件之后)。(如果我更改值并按下 Autopostback="true" CascadingDropDown 设置默认值的按钮)可能导致它或我该如何修复它?
<asp:UpdatePanel ID="PolicyUpdatePanel" runat="server" RenderMode="Block" UpdateMode="Always">
<ContentTemplate>
<%-------------------%>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown_ddlModel" runat="server" TargetControlID="ddlModel"
PromptText="Select it" ServicePath="~/Srv/CascadingDropDownWebService.asmx"
ServiceMethod="GetTransportModel" Category="TransportModel" />
<asp:DropDownList ID="ddlModel" runat="server" DataTextField="Name"
DataValueField="Id" AppendDataBoundItems="True" TabIndex="9" EnableViewState="true">
<asp:ListItem Text="Select it" Value="-1">
</asp:ListItem>
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown_ddlFranchise" runat="server"
ParentControlID="ddlModel" TargetControlID="ddlFranchise" PromptText="Select it"
ServicePath="~/Srv/CascadingDropDownWebService.asmx" ServiceMethod="GetFranchise"
Category="Franshise" />
<asp:DropDownList ID="ddlFranchise" runat="server" DataTextField="Name" DataValueField="ID"
AppendDataBoundItems="True" TabIndex="42" EnableViewState="true" onchange="CheckFranchise();">
<asp:ListItem Text="Select it" Value="-1" />
</asp:DropDownList>
<%-------------------%>
<asp:Button ID="btnSaveCalc" runat="server" Text="Calculate" CssClass="main-input"
CausesValidation="true" ValidationGroup="vgApplication" EnableViewState="false"
TabIndex="73" OnClick="btnSaveCalc_Click" OnClientClick="Validate();" />
而 WebMethod 是
[WebMethod]
public CascadingDropDownNameValue[] GetFranchise(string knownCategoryValues, string category)
{
StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
Guid ModelId = new Guid(kv["TransportModel"]);
DamageFranchiseList list = new DamageFranchiseList();
list.FillVisibleByModelId(ModelId);
List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
int i = 0;
foreach (var item in list)
{
i = i + 1;
values.Add(new CascadingDropDownNameValue(item.Name.ToString(), item.ID.ToString(), list.Count >= 4 ? i == 4 : i == list.Count));
}
return values.ToArray();
}