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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:36:49+00:00 2026-06-17T22:36:49+00:00

I had populated an ASP.net dropdown list with AJAX now I need to get

  • 0

I had populated an ASP.net dropdown list with AJAX now I need to get the Id to store in into the database in a C# method, (I’m using LINQ)

This is my webmethod

[WebMethod]
public static ArrayList GetLanguageList()
{
    ArrayList lstArrLanguage = new ArrayList();
     IQueryable<Common.Town> myList = new SupplierBL().GetTowns();
     foreach(Common.Town t in myList)
    {
        string name = t.Name;
        string id = t.TownId.ToString();
        lstArrLanguage.Add(new ListItem(name, id));
    }

    return lstArrLanguage;
}

My test.aspx code

<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "test.aspx/GetLanguageList",
            data: '',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                $("#ddlLanguage").empty().append($("<option></option>").val("[-]").html("Please select"));
                $.each(msg.d, function () {
                     $('#<%=ddlLanguage.ClientID%>').append($("<option></option>").val(this['Value']).html(this['Text']));
                });
            },
            error: function () {
                alert("An error has occurred during processing your request.");
            }
        });
    });
</script>
  • 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-17T22:36:50+00:00Added an answer on June 17, 2026 at 10:36 pm

    You can’t get selected value from DropDownList if you adding options in javaScript. You can try the following

    string selectedValue = Request.Form[ddlLanguage.UniqueID];
    

    This question may be useful also.

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

Sidebar

Related Questions

I had a working solution using ASP.NET MVC Preview 3 (was upgraded from a
Had a problem with the recursive conflictCheck() method. That seems fine now. I have
i am using firefox 3.63 with asp.net mvc2 in vs 2010.the thing is that
I have an asp.net Dropdownlist with autopostback enabled. It is not populated dynamically, its
In an ASP.NET ListView control, populated from an ObjectDataSource, how would I show N/A
I have a pre-populated sqlite database and I need to attach this within my
I'm reading up to get a better idea of how viewstate works in asp.net
Short version: How do I incorporate my custom ASP.NET/VB.NET stuff into a DNN site?
So I have a cascading dropdown of sorts, but using List Boxes. When an
I have a list populated from a sqlite database with data values ranging from

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.