コード例 #1
0
    protected void setupDisplayDataCascadingDropDown()
    {
        // now, let's set up the cascading
        CascadingPair pair = new CascadingPair()
        {
            ParentDropDownID = ddlDataType.ID, ChildDropDownID = ddlDisplayType.ID
        };

        // and let's apply the dependencies properly
        foreach (ListItem dataType in ddlDataType.Items)
        {
            var dependentDisplayTypes =
                FieldMappings.GetDependentDisplayTypesFor(dataType.Value.ToEnum <FieldDataType>());
            ParentDropDownValue v = new ParentDropDownValue()
            {
                Value = dataType.Value
            };
            foreach (var dependentDisplayType in dependentDisplayTypes)
            {
                v.ChildDropDownValues.Add(new ChildDropDownValue()
                {
                    Value = dependentDisplayType.ToString()
                });
            }

            pair.ParentDropDownValues.Add(v);
        }
        CascadingDropDownManager1.CascadingPairs.Add(pair);
    }