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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:12:14+00:00 2026-06-18T07:12:14+00:00

I need to bind the value in html select option and I have the

  • 0

I need to bind the value in html select option and I have the values in a C# model. How do I do this? My html code:

 <div class="Div"><span class="label2">values:</span>
    <select id="Binding_values" onchange="values()></select></div>
  • 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-18T07:12:16+00:00Added an answer on June 18, 2026 at 7:12 am

    Assuming you have a view model:

    public class MyViewModel
    {
        public string SelectedValue { get; set; }
        public IEnumerable<SelectListItem> Items { get; set; }
    }
    

    and a controller action which will populate this view model and pass it to the view:

    public ActionResult Index()
    {
        var model = new MyViewModel();
        model.Items = new[]
        {
            // TODO: those values could come from a database for example
            new SelectListItem { Value = "1", Text = "item 1" },
            new SelectListItem { Value = "2", Text = "item 2" },
            new SelectListItem { Value = "3", Text = "item 3" },
        };
        return View(model);
    }
    

    inside the corresponding strongly typed view you could use the DropDownListFor helper:

    @model MyViewModel
    ...
    @using (Html.BeginForm())
    {
        @Html.DropDownListFor(x => x.SelectedValue, Model.Items)
        <button type="submit">OK</button>
    }
    

    and if this dropdown is inside an HTML for posting back to the controller you could have an action that will retrieve the selected value from the model:

    [HttpPost]
    public ActionResult Index(MyViewModel model)
    {
        // model.SelectedValue will contain the selected value from the dropdown list here
        ...
    }
    

    Assuming you want to send the selected value to the server immediately after changing the selection in the dropdown without clicking on a form submit button you could give this DropDownList an unique id:

    @Html.DropDownListFor(x => x.SelectedValue, Model.Items, new { id = "myDdl" })
    

    and then subscribe to the .change() event of this dropdown using jQuery and submit the containing form:

    $(function() {
        $('#myDdl').change(function() {
            $(this).closest('form').submit();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: var li = $('<li>',{ html : '<div class=header>' + header
I have a dropdown. I need to bind with two field of datatable value
How to bind json value to script and need a output in html. I
I have a situation where I need to programatically select an option within a
given this html code: <td><img class='del' id='4' src='images/delete.gif'></td> I am in trouble understanding how
I need to bind to a Storyboard, but I cant figure how. I have
I have a situation where I need to bind a click event to an
I almost have this solved but need a little push. Here's what I have:
I have a textbox that I am defining as <%= Html.TextBox(Username, Model.Form.Username, new {
I have XML files that are representation of a portion of HTML code. Those

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.