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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:28:41+00:00 2026-06-17T23:28:41+00:00

I am trying to use Html.DropDownListFor to build a dropdown list and get the

  • 0

I am trying to use Html.DropDownListFor to build a dropdown list and get the user selected value. I can get the list to display but cannot figure out how to get the link to pass the selected value.
I have the following model:

public partial class ProductVariant
{
    public int ID { get; set; }
    public string Sku { get; set; }
}

The following ViewModel:

public class SkuToDiscountViewModel
{
    public int ID { get; set; }
    public string Sku { get; set; }
    public IEnumerable<ProductVariant> Products { get; set; }
}

The following Controller action:

public ViewResult Index()
    {
       SkuToDiscountViewModel sModel = new SkuToDiscountViewModel();
        List<ProductVariant> prodSkus = db.ProductVariants.ToList();
        sModel.Products = prodSkus;
        return View(sModel);
    }

The following view:

@model mySpace.ViewModel.SkuToDiscountViewModel
@{
    ViewBag.Title = "Index";
 }
 <h2>Index</h2>
 @using(Html.BeginForm())
    {
       Html.DropDownListFor(x=>x.ID,
       new SelectList(Model.Products,"ID", "Sku", Model.ID), " select ")
      <p>
          @Html.ActionLink("Edit", "Edit") 
      </p>
    }

Any help is appreciated.

  • 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-17T23:28:42+00:00Added an answer on June 17, 2026 at 11:28 pm

    You need to a submit button to your form:

    @model mySpace.ViewModel.SkuToDiscountViewModel
    @{
        ViewBag.Title = "Index";
    }
    <h2>Index</h2>
    @using(Html.BeginForm())
    {
        Html.DropDownListFor(x=>x.ID,
            new SelectList(Model.Products,"ID", "Sku", Model.ID), " select ")
        <p>
            <input type="submit" value="Save" />
        </p>
    }
    

    Then you need to add an Action to your controller like this:

    [HttpPost]
    public ActionResult Index(SkuToDiscountViewModel postedModel)
    {
        // postedModel.ID will contain the value selected in the drop down list
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the Html.DropDownList extension method but can't figure out how to
I am trying to use document.write(html); in my script but it looks illegal. I
So I'm trying to get a common dropdown list of event types in MVC.
I am trying to use the html file input to get the path and
I'm trying to use jquery.html() to change the content of a div. It can
I'm running into an issue trying to use @Html.DropDownListFor(). I have a model with
I am trying to use Html.EditorFor for a value where I need both a
I'm new to Perl/HTML things. I'm trying to use $mech->get($url) to get something from
I'm having a problem displaying selected value with Html.DropDownListFor. I have a view that
I'm trying to use .html() or .contents() but i have strange behaviours I basically

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.