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

The Archive Base Latest Questions

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

I have a form on a View with a dropdown list, implemented with DropDownListFor().

  • 0

I have a form on a View with a dropdown list, implemented with DropDownListFor(). This View is strongly typed to a ViewModel, which has a SelectList property to hold the options of the dropdown, and then another property to hold the selected value of the dropdown. This is working fine, but what I’d like to do is, hold both the selected value AND selected text of the dropdown in my second property. The reason I want to do this is so that as the form selfposts, I have both the text and value of each selection.

I tried changing the selected value property from an int to a KeyValuePair but only the int part of the pair is set on form submission.

Perhaps there is a better way altogether to accomplish this, I am open to all suggestions including a partial redesign of my methods.

Controller (building SelectList)

SelectList leadTypeGroups = new SelectList(_enrollmentRepository.GetLeadTypeGroups(), "Key", "Value");

ViewModel

public KeyValuePair<int, string> LeadTypeGroupID { get; set; }
public SelectList LeadTypeGroups { get; set; }

View

@Html.DropDownListFor(selected => Model.LeadTypeGroupID, Model.LeadTypeGroups, " ")
  • 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-02T00:00:04+00:00Added an answer on June 2, 2026 at 12:00 am

    Have the sever pull the values from the database (or an in-memory cache) on each request. Alternatively, have a hidden field with javascript that updates it with the appropriate text whenever the dropdown selection changes.

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

Sidebar

Related Questions

this time it's about Ruby On Rails. I have a form in the view
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have this login form. This form is a grouped table view where the
Hello i have a list view control, While the form is being loaded i
The scenario is I have got 2 dropdown list and a table in which
Hi, I have the following in my view : <form id=list_ad method=get class=adListFilter action=<%=Url.Action(List,
I have a dropdown list in an MVC view. On selection change of dropdown
I a have a dropdown list which is being populated from database. It is
I have the following view model: Public Class MyViewModel Public Property SelectedIDs As List(Of
I have simple form. It contains few texboxes and one dropdown list. And I

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.