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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:04:05+00:00 2026-05-16T02:04:05+00:00

Six Five Three One And I have controller: DBEntity context = new DBEntity(); //

  • 0

Six
Five
Three
One

And I have controller:

    DBEntity context = new DBEntity(); // My EntityModel
    public ActionResult Index()
    {
        return View();
    }

    public JsonResult GetStartValues()
    {
        var b = context.MyTable.ToList();
        return Json(ConvertObj(b));
    }
    private object ConvertObj(List<MyTable> lst)
    {
        var list = new object[lst.Count];
        for (int i = 0; i < lst.Count; i++)
        {
            list[i] = new { value = lst[i].MyValue, name = lst_meals[i].MyText };
        }
        return list;
    }

My question is: How to Init this values as start values using jQuery.
I can use solution like this:

    public ActionResult Index()
    {
        var model = context.MyTable.ToList()
        return View(model);
    }

In .aspx

   <select id="myDropdown" name="myDropdown"> 
   <% foreach(var obj in Model.MyTableList) {%>
   <option value="<%: obj.MyValue %>"><%: obj.MyText %></option>
   <% } %>

But I want use Jquery for this)

I want to populate the drop down list by making an asynchronous call to a service, but I don’t know what event I have to use… If I trying to populate drop down:

 $(document).ready(function () {
     $.post("/GetStartValues/", { }, function (data) {
       populateDropdown($("#[id*='myDropdown']"), data);
     });
 }

 function populateDropdown(select, data) {
        select.html(''); //clear all items
        $.each(data, function (id, option) {
            select.append($('<option></option>').val(option.value).html(option.name));
        });
 }

But it isn’t working. I want to insert values into DropDown using Jquery request as soon as page is loaded.

  • 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-16T02:04:05+00:00Added an answer on May 16, 2026 at 2:04 am

    Is your controller returning the correct Ajax?

    I’m not sure what your ConvertObj does but assuming you are returning the Ajax correctly, then this jQuery should work.

    $.ajax({
                url: '/GetStartValues/',
                type: 'POST',
                data: {
                },
                success: function (data) {
                    $('#myDropdown').html('');
                    for (var i=0; i < data.length; i++) {
                        $('#myDropdown').append($('<option></option>').attr('value', data[0].value).text(data[0].name));
                    }
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a string like this: one two three four five six seven
I have an array(list?) in ruby: allRows = [start,one,two,start,three,four,start,five,six,seven,eight,start,nine,ten] I need to run a
I have a table with data : id one two three four five six
lets say I have a list like so: ['one','two','three','four','five','six','seven','eight','nine'] and I want to experiment
I have a single array such as this: array('one','two','three','four','five','six','seven') I'm using a foreach to
trying to take this content: <div class=content>one,two,three</div> <div class=content>four,five,six</div> <div class=content>seven,eight,nine</div> and .split and
my_list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'] Using python, I need list
If I have following map: NavigableMap<Integer,String> nmap = new TreeMap<Integer,String>(); nmap.put(3, Three); nmap.put(1, One);
I have a fiddle code: //create array with values thisArray= ['',[]]; thisArray[0] = ['numbers',['one','two','three','four','five']];
I have the following data. df = data.frame(email_one=c(one@gkn.com,two@wern.com,three@fu.cin, four@huo.com,five@hoi.com), email_two=c(ten@hoinse.com, four@huo.com,two@wern.com,five@hoi.com,six@ihoio.com)) I'm wondering if

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.