Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8575187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:38:15+00:00 2026-06-11T19:38:15+00:00

I have two droplist fields for a template. In the content editor, I want

  • 0

I have two droplist fields for a template. In the content editor, I want it so that the value of the second droplist is dependent on the first droplist. I.e. something like a country/state control. Is there a way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:38:16+00:00Added an answer on June 11, 2026 at 7:38 pm

    There is nothing out of the both that will give you this functionality. You need to create a custom field and implement it.

    EDIT:
    Here is the implementation of a category / subcategory field I have in a sitecore installation

    public class CategoryPicker : Control, IContentField
        {
            #region IContentField Implementation
    
            public string GetValue()
            {
                return string.Format("{0}|{1}",
                                     GetInputControl<Listbox>(ControlNames.MainCategoryDropList).SelectedItem.Value,
                                     GetInputControl<Listbox>(ControlNames.SubCategoryDropList).SelectedItem.Value);
    
            }
    
            public void SetValue(string value)
            {
                Value = value;
            }
    
            #endregion
    
            #region Properties
    
            public string ItemId
            {
                get { return GetViewStateString("ItemID"); }
                set { SetViewStateString("ItemID", value); }
            }
    
            private CategoryIdPair CategoryIdPair
            {
                get
                {
                    Item contextItem = GetItem(ItemId);
                    if (contextItem.Fields["CategoryId"] != null)
                    {
                        return CategoryFieldParser.Parse(contextItem.Fields["CategoryId"].Value);
                    }
                    return CategoryIdPair.Empty;
                }
            }
    
            public bool TrackModified
            {
                get { return GetViewStateBool("TrackModified", false); }
                set { SetViewStateBool("TrackModified", value, false); }
            }
    
            #endregion
    
            public CategoryPicker()
            {
                TrackModified = true;
            }
    
            protected override void OnLoad(EventArgs e)
            {
                if (!Sitecore.Context.ClientPage.IsEvent)
                {
                    Controls.Clear();
                    Controls.Add(CreateMainCategorySelectorControl());
                    Controls.Add(CreateSubCategorySelectorControl());
    
                    SetSelectorOnChangeEvents();
                }
                else
                {
                    var mainCategorySelectorControl = GetInputControl<Listbox>(ControlNames.MainCategoryDropList);
                    var subCategorySelectorControl = GetInputControl<Listbox>(ControlNames.SubCategoryDropList);
                    // if value changed - set modified=true
                    if (mainCategorySelectorControl.SelectedItem.Value != CategoryIdPair.CategoryId.ToString() || subCategorySelectorControl.SelectedItem.Value != CategoryIdPair.SubCategoryId.ToString())
                    {
                        SetModified();
                    }
                }
    
                base.OnLoad(e);
            }
    
            private void SetSelectorOnChangeEvents()
            {
                var mainCategorySelectorControl = GetInputControl<Listbox>(ControlNames.MainCategoryDropList);
                mainCategorySelectorControl.Attributes.Add("onchange",
                                                           Sitecore.Context.ClientPage.GetClientEvent(
                                                            ID + ".ReInitialiseSubCategorySelector"));
                var subCategorySelectorControl = GetInputControl<Listbox>(ControlNames.SubCategoryDropList);
                subCategorySelectorControl.Attributes.Add("onchange",
                                                          Sitecore.Context.ClientPage.GetClientEvent(
                                                            ID + ".SetSubCategoryFieldValue"));
            }
    
            public void ReInitialiseSubCategorySelector()
            {
                var subCategorySelectorControl = GetInputControl<Listbox>(ControlNames.SubCategoryDropList);
                InitialiseSubCategorySelectorControl(subCategorySelectorControl);
                Sitecore.Context.ClientPage.ClientResponse.Refresh(subCategorySelectorControl);
            }
    
            public void SetSubCategoryFieldValue()
            {
                Item contextItem = GetItem(ItemId);
                using (new SecurityDisabler())
                {
                    contextItem.Editing.BeginEdit();
                    contextItem.Fields["CategoryId"].Value = GetValue();
                    contextItem.Editing.EndEdit();
                }   
            }
    
            #region Main Category Dropdown Population
    
            private Listbox CreateMainCategorySelectorControl()
            {
                var mainCategorySelectorControl = new Listbox
                                                    {
                                                        ID = GetID(ControlNames.MainCategoryDropList),
                                                        Disabled = Disabled,
                                                        TrackModified = false
                                                    };
    
                InitialiseMainCategorySelectorControl(mainCategorySelectorControl);
    
                return mainCategorySelectorControl;
            }
    
            private void InitialiseMainCategorySelectorControl(System.Web.UI.Control mainCategorySelectorControl)
            {
                List<Category> mainCategories = //Get main categories;
    
                foreach (Category category in mainCategories)
                    CreateCategoryListItem(category.Description, category.CategoryId, mainCategorySelectorControl, category.CategoryId == CategoryIdPair.CategoryId);
            }
    
            #endregion
    
            #region Sub-Category Dropdown Population
    
            public Listbox CreateSubCategorySelectorControl()
            {
                var subCategorySelectorControl = new Listbox
                                                    {
                                                        ID = GetID(ControlNames.SubCategoryDropList),
                                                        Disabled = Disabled,
                                                        TrackModified = false
                                                    };
    
                InitialiseSubCategorySelectorControl(subCategorySelectorControl);
                subCategorySelectorControl.Value = CategoryIdPair.SubCategoryId.ToString();
                Sitecore.Context.ClientPage.ClientResponse.Refresh(subCategorySelectorControl);
                return subCategorySelectorControl;
            }
    
            public void InitialiseSubCategorySelectorControl(System.Web.UI.Control subCategorySelectorControl)
            {
                var mainCategorySelectorControl = GetInputControl<Listbox>(ControlNames.MainCategoryDropList);
                int mainCategorySelectedValue = Convert.ToInt32(mainCategorySelectorControl.SelectedItem.Value);
    
                subCategorySelectorControl.Controls.Clear();
    
                CreateCategoryListItem("Please select", 0, subCategorySelectorControl, false);
    
                List<SubCategory> subCategories = //Get all subcategories
                foreach (SubCategory subCategory in subCategories)
                {
                    CreateCategoryListItem(subCategory.Description, subCategory.SubCategoryId, subCategorySelectorControl, subCategory.SubCategoryId == CategoryIdPair.SubCategoryId);
                }
            }
    
            #endregion
    
            private static void CreateCategoryListItem(string title, int value, System.Web.UI.Control control, bool selected)
            {
                var listItem = new ListItem
                                {
                                    ID = GetUniqueID(ControlNames.CategoryListItem),
                                    Header = title,
                                    Value = value.ToString(),
                                    Selected = selected
                                };
    
                Sitecore.Context.ClientPage.AddControl(control, listItem);
            }
    
            #region Helper Methods
    
            private T GetInputControl<T>(string controlName) where T : Control
            {
                return FindControl(GetID(controlName)) as T;
            }
    
            private void SetModified()
            {
                if (TrackModified)
                {
                    Sitecore.Context.ClientPage.Modified = true;
                }
            }
    
            private static Item GetItem(string itemId)
            {
                return Sitecore.Context.ContentDatabase.GetItem(new ID(itemId));
            }
    
            #endregion
    
            #region ControlNames Nested Class
    
            private static class ControlNames
            {
                public const string MainCategoryDropList = "MainCategoryDropList";
                public const string SubCategoryDropList = "SubCategoryDropList";
                public const string CategoryListItem = "CategoryListItem";
            }
    
            #endregion
        }
    
        public class CategoryField : CustomField
        {
            public int CategoryId { get; set; }
            public int SubCategoryId { get; set; }
    
            public CategoryField(Field innerField) : base(innerField)
            {
                Assert.ArgumentNotNull(innerField, "innerField");
                var pair = CategoryFieldParser.Parse(innerField.Value);
                CategoryId = pair.CategoryId;
                SubCategoryId = pair.SubCategoryId;
            }
    
            public static implicit operator CategoryField(Field field)
            {
                if (field != null)
                {
                    return new CategoryField(field);
                }
                return null;
            }
        }
    
        public class CategoryFieldParser
        {
            public static CategoryIdPair Parse(string input)
            {
                var pair = input.Split(new[] { '|' });
                return new CategoryIdPair
                        {
                            CategoryId = pair.Length > 0 ? GetIntValue(pair[0]) : CategoryIdPair.Empty.CategoryId,
                            SubCategoryId = pair.Length == 2 ? GetIntValue(pair[1]) : CategoryIdPair.Empty.SubCategoryId
                        };
            }
    
            private static int GetIntValue(string input)
            {
                int result;
                if (int.TryParse(input, out result))
                    return result;
                return 0;
            }
        }
    
        public class CategoryIdPair
        {
            public int CategoryId { get; set; }
            public int SubCategoryId { get; set; }
            public static CategoryIdPair Empty
            {
                get { return new CategoryIdPair {CategoryId = 0, SubCategoryId = 0}; }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes Order and Items I want a method like this class
Have two fields start and end, both are dates, I want to write a
I have two XML files. The first XML has a bunch of nodes that
I have two update panels on a page. And I want to update both
I have two queries that find both the Zip codes, and the States for
I have two droplist in html built using tag. <select name=List1 id=List1 onclick=GetVal()> <option
I have two Hibernate data object. The first is a User (with unique id,
I have two inputs with the same date, but i want to separate the
I have two function, one function is a reload function that does a ajax
Have two events: $('body').mouseup(function(e){} and $('.toggle').click(function(e){} I only want one of these to trigger.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.