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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:32:09+00:00 2026-06-02T06:32:09+00:00

This is my View Code: @using(Html.BeginForm(new { SelectedId = /*SelectedValue of DropDown*/ })) {

  • 0

This is my View Code:

@using(Html.BeginForm(new { SelectedId = /*SelectedValue of DropDown*/ })) {

 <fieldset>

     <dl>
       <dt>
           @Html.Label(Model.Category)
       </dt>
       <dd>
        @Html.DropDownListFor(model => Model.Category, CategoryList)
       </dd>
    </dl>

 </fieldset>
 <input type="submit" value="Search" />


}

As code shown I need to pass the dropdown selected value to the action in BeginForm() Html helper. What is your suggestion?

  • 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-02T06:32:11+00:00Added an answer on June 2, 2026 at 6:32 am

    The selected value will be passed when the form is submitted because the dropdown list is represented by a <select> element. You just need to adapt your view model so that it has a property called SelectedId for example to which you will bind the dropdown:

    @using(Html.BeginForm() )
    {
        <fieldset>
            <dl>
                <dt>
                    @Html.LabelFor(x => x.SelectedId)
                </dt>
               <dd>
                    @Html.DropDownListFor(x => x.SelectedId, Model.CategoryList)
               </dd>
            </dl>
        </fieldset>
    
        <input type="submit" value="Search" />
    }
    

    This assumes the following view model:

    public class MyViewModel
    {
        [DisplayName("Select a category")]
        public int SelectedId { get; set; }
    
        public IEnumerable<SelectListItem> CategoryList { get; set; }
    }
    

    that will be handled by your controller:

    public ActionResult Index()
    {
        var model = new MyViewModel();
        // TODO: this list probably comes from a repository or something
        model.CategoryList = new[]
        {
            new SelectListItem { Value = "1", Text = "category 1" },
            new SelectListItem { Value = "2", Text = "category 2" },
            new SelectListItem { Value = "3", Text = "category 3" },
        };
        return View(model);
    }
    
    [HttpPost]
    public ActionResult Index(MyViewModel model)
    {
        // here you will get the selected category id in model.SelectedId
        return Content("Thanks for selecting category id: " + model.SelectedId);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my controller code and also my View: @using (Html.BeginForm(Create, Product, FormMethod.Post, new
i have this code in View @using (Html.BeginForm()) { @: Location @Html.DropDownList(territryID, (SelectList)ViewBag.Territory, choose
I have a PaartialView declared like this: @model IEnumerable<mvc1.Models.ProjectDetailModel> @using (Html.BeginForm()) <form method=get action=EditProject
I wanted to generate a list view using below code. But after running this
While using this code, i can't get any results... Ext.define('Teste.view.Main', { extend: 'Ext.Container', initialize:
i have a scroll view with multiple images and i am using this code.
This is the code in my view: echo $this->Form->create('Chart'); echo $this->Form->input('username', array('label'=>('Usernames List'), 'empty'=>('Select
I have a view to create a user as follows. <% using (Html.BeginForm(SaveUser, Security))
I have this part in asp.net MVC 3 view: <tr> <td>@Html.LabelFor(x => x.DateOfBirth, new
Using the following form in a view <% using (Ajax.BeginForm(PatientSearch, new {}, new AjaxOptions()

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.