CascadingDropDown始终从WebMethod设置默认值

时间:2012-11-13 14:23:59

标签: ajax default toolkit autopostback cascadingdropdown

我已经更新了Ajax Control Toolkit。 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();
    }

0 个答案:

没有答案