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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:42:55+00:00 2026-05-24T19:42:55+00:00

I’m working on my first ASP.NET MVC 3 application and I’m trying to show

  • 0

I’m working on my first ASP.NET MVC 3 application and I’m trying to show ingredients of a particular ice cream on a create page.

I’ve got a viewmodel for the page which has a structure something like this:

public class IceCreamViewModel
{
   ...
   public IEnumerable<IngredientViewModel> Ingredients { get; set; }
}

(there are other properties but they aren’t germane to the discussion)

Ingredients gets populated by the Create action on the controller and I’ve verified that it contains the data I want.

The IngredientViewModel has the following structure:

public class IngredientViewModel
{
   public int Id { get; set; }
   public string Name { get; set; }
   public bool IsChecked { get; set; }
}

In the Create view I have tried to display the collection of ingredients to allow the user to check which are in the recipe (e.g., peanuts, egg, etc.) and I’m doing something like this:

@Html.EditorFor(m => m.Ingredients)

I’ve written and editor template for this that looks like so:

@model IceCream.ViewModels.Ingredients.IngredientViewModel
<div>
  @Html.HiddenFor(m => m.Id)
  @Html.LabelFor(m => m.Name)
  @Html.CheckBoxFor(m => m.IsChecked)
</div>

What I’d expect to show up is a bunch of labels and checkboxes for each of my ingredients, but what shows up is the correct number of label/checkbox entries but they all say “Name” rather than the ingredient name that is in the IngredientViewModel. So I’m certainly doing something wrong here. It obviously knows that it has N items to iterate through but it isn’t picking up the properties of those items. Guidance?


Update

So, all I ended up doing was switching my LabelFor to a TextBoxFor and my values showed up… as they would, of course. (tired, long day) – @LabelFor uses the name of the property, or the annotated DisplayName for the property. Things work fine now… move along, nothing to see here…

  • 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-24T19:42:56+00:00Added an answer on May 24, 2026 at 7:42 pm

    You’re trying to create a label for the Name property (as if you wanted the user to edit the Ingredient Name), instead of actually showing the name as the label for the checkbox.

    How about changing:

    @Html.LabelFor(m => m.Name)
    

    … to:

     @m.Name
    

    Or, better yet:

    @model IceCream.ViewModels.Ingredients.IngredientViewModel
    <div>
      @Html.HiddenFor(m => m.Id)
      <label for="@m.Id">@m.Name</label>
      @Html.CheckBoxFor(m => m.IsChecked)
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.