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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:20:50+00:00 2026-05-27T06:20:50+00:00

We’re working on a big ASP.NET\VB.NET website project. I need to populate three dropdownlists.

  • 0

We’re working on a big ASP.NET\VB.NET website project.
I need to populate three dropdownlists. To last two are independent of the previous ones. The population data comes from an SQL Server. I’d have no problem doing this with code-behind with post back but we don’t want any PostBacks so I started to develop this in Ajax\jQuery.

Preface:

The dropdownlist’s values and text are both different and tied up to the database. Server-side, the function called by the Ajax method returns a list of list of string with the values and text, i.e.

list[0][0] = "ID0" 
list[0][1] = "VP" 

The list is well built and returns the right value taken from the database.

Problem:

Now I want to populate the dropdownlist from the list sent to the ajax success response and I have a hard time doing it.

Here’s the ajax part of it so far

$.ajax(
        {
            type: "POST",
            url: "Projet.aspx/GetDir",
            data: "{VP:'" + dd_effort_vp + "',DP:'" + dd_effort_dp + "',Direction:'" + dd_effort_d + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(response) {
                // This code works if only a simple list of string is 
                // returned from the server-side called function.
                var cars = response.d;

                $.each(cars, function(index, value) {
                        $('#<%= dd_effort_directionp.clientid()%>').append(
                       $('<option></option>').val(value).html(value));
                });
            }

This code works IF and only IF I have a simple list of string returned by the server side function.

Now I want to modify it to get the values from the List of List of String (in var cars and assign the right ID and Description to each item in the newly populated DropdownList.

  • 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-27T06:20:51+00:00Added an answer on May 27, 2026 at 6:20 am

    If your server is returning to you a list of list of strings, that will come to jQuery via an array, whose elements are arrays. You need to figure out/know which element of that array—which, again, will contain a list of strings—needs to go with your dropdown. If you want the 0th array, you would do:

    var cars = response.d[0];
    

    Also, it looks like you’re going through a lot of trouble to find the relevant dropdown lists since asp.net is giving them unpredictable names.

    Consider giving each drop down a unique class, via the CssClass property, and then select it that way.

    <asp:DropDownList runat="server" CssClass="dd_effort_directionp"></asp:DropDownList>
    
    $.each(cars, function(index, value) {
         $(".dd_effort_directionp").append(
             $("<option />").val(value).html(value));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
In my XML file chapters tag has more chapter tag.i need to display chapters
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.