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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:59:11+00:00 2026-05-27T10:59:11+00:00

I want to bind the HTML select element with the database. I want to

  • 0

I want to bind the HTML select element with the database.

I want to bind the text and value of select element

The problem is dont want to return the string array with text and value of each option combined using some symbol rather i want to return an array list or some List

Now after returning using PageMEthods i cannot iterate over the result to get the id and value of select options.

I cannot use JSON i have to use PageMethods only.

ArrayList obj = new ArrayList();

var countries = EntityService.ServiceInstance.GetCountries();

foreach (var country in countries)
{
    ListItemClass temp = new ListItemClass();

    temp.ListItemText = country.country_name.ToString();
    temp.ListItemValue = country.id.ToString();

    obj.Add(temp);
}

return obj;

What I want is how can I get the ID and country name in jQuery

Any help is appreciated.

Thanks

PROBLEM SOLVED:

I need to write :

where test is the return type of method

$.each(test,
    function (intIndex, objValue) {
        $.each(objValue, function (intIndex1, objValue1) {
            alert(objValue1);
        })
    }
);

But dont know whether this is a correct approach or not.

  • 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-27T10:59:12+00:00Added an answer on May 27, 2026 at 10:59 am

    Finally this worked for me:

    Where result is the returned using page methods.

    THough this might not be the best way.

    function bind_select(result, el_name) {
    
    $.each(result,
             function (intIndex, objValue) {
    
                 var option_text;
                 var option_value;
    
                 $.each(objValue,
             function (object_property, objValue1) {
    
                 if (object_property == "ListItemText") {
                     option_text = objValue1;
                 }
                 else {
                     option_value = objValue1;
                 }
             })
    
                 $('#' + el_name).append($("<option></option>").
                  attr("value", option_value).
                  text(option_text));
    
             })
      }
    

    Any other ideas are appreciable

    Thanks.

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

Sidebar

Related Questions

i have an input element, and i want bind both change and keypress event
The problem: We want to bind a HierarchicalDataTemplate’s ItemsSource property to a CollectionViewSource, to
In an HTML table I want to select some items, I use jQuery in
if i want to bind the value-attribute of a h:selectmanycheckbox to a map, with
I am having a html dropdown <select id=ExternalIp onchange=externalIpchange()></select> I bind the data to
I want to get the selected value in a list. <html > <head> <meta
i want to bind to the display style property of my Html.TextBox <%= Html.TextBox(RunDates,
I want to bind something like this: For CSS, HTML files: <c-space> <c-x><c-n> For
I have an html select: <select> <option>Choose one</option> </select> Using jQuery, is there an
I want to bind my UI against a collection of XElements and their properties

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.