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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:47:10+00:00 2026-05-29T10:47:10+00:00

I cannot figure out how to pass the text from a <SelectListItem> with a

  • 0

I cannot figure out how to pass the text from a <SelectListItem> with a DropDownList from one view to another.

I am using the following in a view:

@using (Html.BeginFormAntiForgeryPost())
{ 
    @Html.Hidden("myData", new MvcSerializer().Serialize(Model, SerializationMode.Signed))
    ...
    @Html.DropDownListFor(m => m.MyProperty, new SelectList(Model.MyPropertyList, "Value", "Text"))
    ...
}

In my ViewModel (MyData), I have:

[Serializable]
public class MyData
{
public int MyProperty{ get; set; }
public IEnumerable<SelectListItem> MyPropertyList{ get; set; }
...
public MyData()
    {
        var mypropertylist = new List<SelectListItem>() {
            new SelectListItem { Text = "(Please select)" },
            new SelectListItem { Value = "1", Text="Some text." },                
            new SelectListItem { Value = "2", Text="Some other text." }
            };
        this.MyPropertyList = mypropertylist; //Edited
    }
}

I am using a wizard and want to pass the data collected in one step to either the confirmation page or an e-mail my code generates.

For example, if I do @Html.EditorFor(m => m.FirstName) in a view, I can pass that input into a confirmation view by doing @Model.FirstName.

I have RadioButtons for which I am able to do the following: @Html.Raw(MyNamespace.ViewModels.MyModel.MyPropertyDictionary.mypropertyDictionary[Model.MyProperty]) to pass the data to my confirmation view. But I am unable to properly create the @Html.Raw (assuming that’s what I’d have to do) for a DropDown.

Thanks!

UPDATE (To add controller code per comment request):

Controller:

private MyData myData;
....
//
// STEP 1:
// AskUs
public ActionResult AskUsDetails(string nextButton)
{
    if ((nextButton != null) && ModelState.IsValid)
        return RedirectToAction("AskUsSubmitted");
    return View("AskUs/Details", myData);
}
//
// STEP 2:
// AskUs/Submitted
public ActionResult AskUsSubmitted()
{
    // Todo: Save myData database; render a "Submitted" view
    MyMailer.AskUs(myData).Send();
    return View("AskUs/Submitted", myData);
}

Things to note:

  1. There is a serialization part to the controller. I don’t know if its relevant (let me know if it is and I will edit inside the code above).
  2. Using MvcMailer, so there are 2 other files involved, but again I don’t know if its relevant (it’s the MyMailer.AskUs(myData).Send(); part above).

UPDATE:

If I do @Model.MyPropertyList in the confirmation view, my view shows

System.Collections.Generic.List1[System.Web.Mvc.SelectListItem]

If I use @Model.MyProperty I am getting the value, e.g.,

1 

I just need to figure out how to output the actual “Text” contained, for example, in

new SelectListItem { Value = "1", Text="**Some text.**" }

Any examples of how to do that would be much 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-05-29T10:47:11+00:00Added an answer on May 29, 2026 at 10:47 am

    When you submit a form containing a dropdown list, only the selected value is sent to the server. If you wanted to fetch the corresponding text you could use this selected value and search into the corresponding list.

    Also you don’t need to manually add the (Please select) item to your collection. This could be done in the view directly:

    @Html.DropDownListFor(
        m => m.MyProperty, 
        Model.MyPropertyList, 
        "(Please select)"
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot figure out how to write the following query using the DbFinderPlugin 1.2.2
I have this little problem, that I cannot figure out which arguments to pass
I cannot figure out how to convert this code from C# to VB.net. It
I cannot figure out how to pass (constant) arguments into my Windows service when
I've looked around and cannot figure this one out: I have a object that
I cannot figure out how to change the title bar icon (the icon in
I cannot figure out a way to disable a container AND its children in
I cannot figure out how to enable per-session instances for my WCF service while
I cannot figure out how to make a C# Windows Form application write to
I cannot figure out why I get this error during check-in. I checked in

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.