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 7516545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:09:54+00:00 2026-05-30T01:09:54+00:00

I have two dropdowns categories and subcategories on my page. Also I have an

  • 0

I have two dropdowns categories and subcategories on my page. Also I have an htmleditor on the same page. Below is my aspx

<div class="clearfx">
    </div>
     <div>
         <label>
             Description :
                </label>
                 <div style="padding-left: 10px; margin-left: 146px;">
                    <cc:HtmlEditor ID="Editor" runat="server" Height="600px" Width="850px" EnableViewState="true" />
                            </div>
                        </div>
                        <div class="clearfx">
                        </div>
                        <div>
                            <asp:UpdatePanel runat="server" ID="up" UpdateMode="Always" ChildrenAsTriggers="true">
                                <ContentTemplate>
                                    <label>Category : </label>
                                    <asp:DropDownList runat="server" ID="Categories" Width="200px" AutoPostBack="True"
                                        OnSelectedIndexChanged="CategoriesSelectedIndexChanged">
                                    </asp:DropDownList>
                                   <asp:RequiredFieldValidator ID="rfvCountry" runat="server" ErrorMessage="Choose a category."
                                        ControlToValidate="Categories" Display="None" EnableTheming="False" EnableViewState="False"
                                        InitialValue="-1" SetFocusOnError="True" ValidationGroup="grpReg"></asp:RequiredFieldValidator>
                                    <asp:ValidatorCalloutExtender ID="rfvCountry_ValidatorCalloutExtender" runat="server"
                                        Enabled="True" TargetControlID="rfvCountry">
                                    </asp:ValidatorCalloutExtender>
                                     <asp:ImageButton runat="server" ID="Refresh" ImageAlign="AbsMiddle" 
                                        ImageUrl="~/cdn/images/refresh.png" onclick="RefreshClick"/> 
                                         <span class="helptext">(click on refresh image, incase subcategories do not load.)</span>
                                </ContentTemplate>

                            </asp:UpdatePanel>

                        </div>
                        <div class="clearfx">
                        </div>

<div>
                            <label>
                                Sub Category :
                            </label>
                            <asp:DropDownList runat="server" ID="SubCategories"  Width="200px">
                            </asp:DropDownList>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Choose a sub category."
                                ControlToValidate="SubCategories" Display="None" EnableTheming="False" EnableViewState="False"
                                InitialValue="-1" SetFocusOnError="True" ValidationGroup="grpReg"></asp:RequiredFieldValidator>
                            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" Enabled="True"
                                TargetControlID="RequiredFieldValidator2">
                            </asp:ValidatorCalloutExtender>
                        </div>

What I am doing is that, On the selected index change of the categories dropdown i am populating subcategories. to suppress post back i am using an Update Panel, But my problem is that,the selected index change is fired but the dropdown subcategories does not gets binded. When I remove the update panel, then its works fine, but my html editor looses its value, even having its own and Page enableviewstate = true. Please help me.

My Codebehind methods are:
Dropdown Selected Index Change Event:

protected void CategoriesSelectedIndexChanged(object sender, EventArgs e)
        {
            if (Categories.SelectedIndex > 0)
            {
                BindSubCategory(Common.ParseInt(Categories.SelectedItem.Value));
            }
            else
            {
                SubCategories.SelectedIndex = 0;
                SubCategories.Items.Clear();
            }
        } 

Page Load Event:

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
                BindCategories();
            }
        }

 private void BindCategories()
        {
            List<Category> cat = _categoryRepository.GetAll().ToList();
            Common.BindDropdown(cat, Categories); // static method
        }
 public static class Common
    {
 /// <summary>
        /// 
        /// </summary>
        /// <param name="list"></param>
        /// <param name="ddl"></param>
        public static void BindDropdown(IList list, DropDownList ddl)
        {
            if (list.Count>0)
            {


                    ddl.DataSource = list;
                    ddl.DataTextField = "Name";
                    ddl.DataValueField = "Id";
                    ddl.DataBind();
                    ddl.Items.Insert(0, new ListItem("---Select---", "-1"));

            }
        }
}
  • 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-05-30T01:09:55+00:00Added an answer on May 30, 2026 at 1:09 am

    Try this:

    <div class="clearfx"> 
    </div> 
    
    <div> 
        <label> Description : </label> 
        <div style="padding-left: 10px; margin-left: 146px;"> 
            <cc:HtmlEditor ID="Editor" runat="server" Height="600px" Width="850px" EnableViewState="true" /> 
        </div> 
    </div> 
    
    <div class="clearfx"> 
    </div> 
    
    
    <asp:UpdatePanel runat="server" ID="up" UpdateMode="Always" ChildrenAsTriggers="true"> 
        <ContentTemplate> 
            <div>
                <label>Category : </label> 
                <asp:DropDownList runat="server" ID="Categories" Width="200px" AutoPostBack="True" 
                    OnSelectedIndexChanged="CategoriesSelectedIndexChanged"> 
                </asp:DropDownList> 
                <asp:RequiredFieldValidator ID="rfvCountry" runat="server" ErrorMessage="Choose a category." 
                    ControlToValidate="Categories" Display="None" EnableTheming="False" EnableViewState="False" 
                    InitialValue="-1" SetFocusOnError="True" ValidationGroup="grpReg"></asp:RequiredFieldValidator> 
                <asp:ValidatorCalloutExtender ID="rfvCountry_ValidatorCalloutExtender" runat="server" 
                    Enabled="True" TargetControlID="rfvCountry"> 
                </asp:ValidatorCalloutExtender> 
                <asp:ImageButton runat="server" ID="Refresh" ImageAlign="AbsMiddle"  
                    ImageUrl="~/cdn/images/refresh.png" onclick="RefreshClick"/>  
                <span class="helptext">(click on refresh image, incase subcategories do not load.)</span> 
    
                <div class="clearfx"> 
                </div> 
    
                <div> 
                    <label> Sub Category : </label> 
                    <asp:DropDownList runat="server" ID="SubCategories"  Width="200px"> 
                    </asp:DropDownList> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Choose a sub category." 
                        ControlToValidate="SubCategories" Display="None" EnableTheming="False" EnableViewState="False" 
                        InitialValue="-1" SetFocusOnError="True" ValidationGroup="grpReg"></asp:RequiredFieldValidator> 
                    <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" Enabled="True" 
                        TargetControlID="RequiredFieldValidator2"> 
                    </asp:ValidatorCalloutExtender> 
                </div>
    
            </div>  
        </ContentTemplate> 
    </asp:UpdatePanel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two dropdowns and a gridview (lstDivisions, lstDistricts, gridIncidents) in an asp.net page
I have a form on my page which contains two select dropdowns. The first
I have two dropdowns @using (Html.BeginForm()) { <fieldset> <legend></legend> <label>User details</label> <section> @Html.LabelFor(model =>
I have two dropdowns in extjs,based on the first dropdwon,the second dropdown populates.This is
I have created a populated dropdown list in HTML. When the two dropdowns have
I have a navigation bar that has two dropdowns (as nested ul's). I'm trying
I have two drop downs on a page whose backing bean is Request Scoped.
I have two dropdowns in my form. The first one Queries for a set
Can I refresh a HTML component in JSP? I have two dropdowns. On selection
I have two dropdowns in html. Both dropdowns are getting data mysql first dropdown

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.