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

  • Home
  • SEARCH
  • 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 8049123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:41:54+00:00 2026-06-05T06:41:54+00:00

I have two drop down lists; the first is bound to an entity datasource,

  • 0

I have two drop down lists; the first is bound to an entity datasource, and the second changes depending on what the user selected from the first list (Initially it is pre-populated based on the first drop down as well). For some reason the data from the second list is not being saved to the database and I can’t figure out why.

Here is my formview:

<asp:FormView ID="FormView1" runat="server" DataKeyNames="SuggestionID" OnItemCommand="FormView1_ItemCommand" OnItemUpdated="FormView1_ItemUpdated"
    DataSourceID="UpdateSuggestionEntity" DefaultMode="Edit" OnDataBound="FormView1_Databound" OnItemUpdating="Formview1_OnItemUpdating">
    <EditItemTemplate>
            <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" 
                DataSourceID="ServiceAreaEntity" DataTextField="ServiceAreaConcatenated" AutoPostBack="true" 
                DataValueField="ServiceAreaID" SelectedValue='<%# Bind("ServiceAreaID") %>'>
            </asp:DropDownList>
            <asp:DropDownList ID="DropDownList2" runat="server" OnPreRender="AddEmptySelect">
            </asp:DropDownList>
        <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" 
            CommandName="Update" Text="Update" />
        &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" 
            CausesValidation="False" CommandName="Cancel" Text="Cancel" />
    </EditItemTemplate>
</asp:FormView>

Here is what I have set up in my code behind:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            DigitalSuggestionBox.Data_Access.DigitalSuggestionBox_Entities context = new DigitalSuggestionBox.Data_Access.DigitalSuggestionBox_Entities();
            DropDownList DropDownList2 = (DropDownList)FormView1.FindControl("DropDownList2") as DropDownList;
            int ID = Int32.Parse(Request.QueryString["SuggestionID"]);
            var suggestion = from u in context.Suggestions
                             where u.SuggestionID == ID
                             select u;
            foreach (var i in suggestion) {
                var subServiceArea = from u in context.SubServiceAreas
                                    where u.ServiceAreaID == i.ServiceAreaID
                                    select u;
                DropDownList2.DataSource = subServiceArea;
                DropDownList2.DataTextField = "SubServiceAreaName";
                DropDownList2.DataValueField = "SubServiceAreaID";
                DropDownList2.DataBind();
                DropDownList2.SelectedValue = i.SubServiceAreaID.ToString();
            }
        }
    }

    // Dynamically populate the SubService Area Dropdown
    protected void DropDownList1_SelectedIndexChanged(Object sender, EventArgs e) {
        DigitalSuggestionBox.Data_Access.DigitalSuggestionBox_Entities context = new DigitalSuggestionBox.Data_Access.DigitalSuggestionBox_Entities();
        DropDownList DropDownList1 = (DropDownList)FormView1.FindControl("DropDownList1") as DropDownList;
        DropDownList DropDownList2 = (DropDownList)FormView1.FindControl("DropDownList2") as DropDownList;
        int valueSelected = Int32.Parse(DropDownList1.SelectedItem.Value);
        var subServiceArea = from u in context.SubServiceAreas
                             where u.ServiceAreaID == valueSelected
                             select u;
        DropDownList2.DataSource = subServiceArea;
        DropDownList2.DataValueField = "SubServiceAreaID";
        DropDownList2.DataTextField = "SubServiceAreaName";
        DropDownList2.DataBind();
    }

    protected void AddEmptySelect(Object sender, EventArgs e) {
        DropDownList DropDownList2 = (DropDownList)FormView1.FindControl("DropDownList2") as DropDownList;
        DropDownList2.Items.Insert(0, new ListItem("- Select -", "0"));
    }

Why does everything else get saved correctly except for DropDownList2? It completely ignores whatever value the user selects in that drop down. It’s bound correctly (everything appears correctly) but doesn’t seem to get submitted with the rest of the formview.

  • 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-05T06:41:55+00:00Added an answer on June 5, 2026 at 6:41 am

    I kept digging around and found this article:
    http://www.codeproject.com/Questions/191898/DropDownList-and-capturing-values-after-SelectedIn

    I feel like there is a better way to do this, but I haven’t figured any out and this method works like a charm. If anyone would like to contribute I’d be interested to see what other solutions are possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control in a master page with two drop down lists.
In my application i have two drop down boxes first box had origin second
Currently, I have two drop down lists that are populated with users' first and
There will be two drop down lists, First have the list of mobile vendor,
I have two Drop Down Lists, the second ones are based off which one
I have two drop-down lists populated from an array of same dates stored in
I have two drop down lists. Second one is populated based on value chosen
i have two dropdown list. first drop down:1 enter code here <form:select path=custName id=custName>
I have two drop down lists: <select name="branch"> <option value="b">Blacksburg</option> <option value="c">Christiansburg</option> <option value="f">Floyd</option>
I have a drop down list and some styles applied to it from two

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.