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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:11:51+00:00 2026-05-16T22:11:51+00:00

I have a cascading dropdown list on my page. The first dropdown contains a

  • 0

I have a cascading dropdown list on my page. The first dropdown contains a list of events. The second dropdown contains a list of attendees. When an event is selected, an AJAX call is made to get the list of attendees for that event, and populate the second dropdown.

My problem is that for the attendees dropdown, I want the user to be redirected to a URL on the SelectedIndexChanged event, with the selected value in the query string. But on the SelectedIndexChanged event, all the items in the second dropdown are reset. Here’s my code:

<script type="text/javascript" language="javascript">      

    $(document).ready(function()
    {
        $('#<%= ddlEvents.ClientID %>').change(function() 
        {
           $.ajax({
               type: "POST",
               url: 'Default.aspx/PopulateAttendees',
               data: '{EventId: ' + $('#<%= ddlEvents.ClientID %>').val() + '}',
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               success: OnAttendeesPopulated
           });
        });


        function OnAttendeesPopulated(response)
        {
            var attendees = response.d;
            var attendeesDropdown = $("#<%= ddlAttendees.ClientID %>");

            attendeesDropdown.removeAttr("disabled");
            $.each(attendees, function()
            {
                attendeesDropdown.append($("<option</option>").val(this['Value']).html(this['Text']));
            });
        }
    });

</script>

<asp:DropDownList ID="ddlEvents" runat="server"></asp:DropDownList>
<br /><br />
<asp:DropDownList ID="ddlAttendees" runat="server" Enabled="false" onselectedindexchanged="ddlAttendees_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>

And in my code-behind:

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        //Bind dropdown to Events
        ddlEvents.DataSource = EventsList();
        ddlEvents.DataTextField = "Name";
        ddlEvents.DataValueField = "EventID";
        ddlEvents.DataBind();
    }
}


[System.Web.Services.WebMethod]
public static ArrayList PopulateAttendees(int EventId)
{
    ArrayList attendees = new ArrayList();
    attendees = GetAttendees(EventId);

    return attendees;
}


protected void ddlAttendees_SelectedIndexChanged(object sender, EventArgs e)
{
    string AttendeeId = ddlAttendees.SelectedValue;

    Response.Redirect("http://mysite.com?id=" + AttendeeId);
}

When the SelectedIndexChanged event is hit, ddlAttendees is empty.

Does anyone know how I can keep the items in ddlAttendees?

  • 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-16T22:11:52+00:00Added an answer on May 16, 2026 at 10:11 pm

    I’d be tempted to include a client-side index changed event which writes the attendee ID to a hidden field before posting back. Then access this field from the codebehind. I think the ddl is losing state because it is populated client-side (I know these two statements sound contradictory!). But I think the hidden field will be persisted much more reliably than the ddl.

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

Sidebar

Related Questions

I am using the AJAX Cascading drop down list but want to add event
So I have a cascading dropdown of sorts, but using List Boxes. When an
I have written a cascading drop down list using JQuery. The code that I
I'm planning to create a cascading dropdown list of Country--> State/Province--->Zip code using geonames.
I have a login.jsp page which contains a login form. Once logged in the
I have cascading data-bound combo boxes, however, if the second of the two boxes
I have a page that has several ListBox es that have some cascading filtering
So I have a UserControl with some cascading DropDownList s on it. Selecting from
I have a Postgresql database on which I want to do a few cascading
I have a web page with various controls. Two of them are dropdownlists. The

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.