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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:06:15+00:00 2026-05-17T23:06:15+00:00

The title just about says it all. I have a complex EF4 entity object

  • 0

The title just about says it all. I have a complex EF4 entity object that has a list of smaller objects I’d like to bind to checkboxes within my view. I just can’t figure out how to satisfy the first argument of Html.CheckboxFor(). Intellisense keeps giving me an error.

Here’s my view models:

public class PlatformListing
{
    public Platform Platform { get; set; }
    public bool IsSelected { get; set; }
}

public class AdminGameReviewViewModel
{
    public Game GameData { get; set; }
    public List<Genre> AllGenres { get; set; }
    public List<PlatformListing> AllPlatforms { get; set; }
}

And my (most likely horrible) controller code which populates the AdminGameReviewViewModel and sends it to the view:

    public ActionResult EditReview(int id)
    {
        var game = _siteDB.Games.Include("Genre").Include("Platforms").Include("Content").Single(g => g.GameID == id);
        var genres = _siteDB.Genres.OrderBy(g => g.Name).ToList();
        var platforms = _siteDB.Platforms.OrderBy(p => p.Name).ToList();
        List<PlatformListing> platformListings = new List<PlatformListing>();

        foreach (Platform platform in platforms)
        {
            platformListings.Add(new PlatformListing { Platform = platform, IsSelected = game.Platforms.Any(p => p.PlatformID == platform.PlatformID) ? true : false });
        }

        var model = new AdminGameReviewViewModel { GameData = game, AllGenres = genres, AllPlatforms = platforms }; 

        return View(model);
    }

I’m just not sure what I’m missing, and it’s driving me nuts. The documentation I’ve found hasn’t really shed any light on it, either.

EDIT: relevant view code (partial view to be used for both Create and Edit) –

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<HandiGamer.ViewModels.AdminGameReviewViewModel>" %>

<p>
    <%: Html.Label("Game Title") %>
    <%: Html.TextBoxFor(model => model.GameData.GameTitle) %>
    <%: Html.ValidationMessageFor(model => model.GameData.GameTitle) %>
</p>
<p>
    <%: Html.LabelFor(model => model.GameData.Genre) %>
    <%: Html.DropDownList("Genre", new SelectList(Model.AllGenres, "GenreID", "Name", Model.GameData.GenreID)) %>
</p>
<p>
    <%: Html.Label("Platforms") %><br />
    <% foreach(var item in Model.AllPlatforms) { %>
        <%: item.Platform.Name %> <%: Html.CheckBox("Platforms[]", item.IsSelected, new { id = item.Platform.PlatformID }) %><br />
    <% } %>
</p>
<p>
    <%: Html.Label("Review Title") %>
    <%: Html.TextBoxFor(model => model.GameData.Content.Title) %>
</p>
<p>
    <%: Html.Label("Review") %>
    <%: Html.TextAreaFor(model => model.GameData.Content.Text) %>
</p>
<p>
    <%: Html.Label("Review Score") %>
    <%: Html.DropDownList("Score", new SelectList(new int[] {1, 2, 3, 4, 5}, "ReviewScore")) %>
</p>
<p>
    <%: Html.LabelFor(model => model.GameData.Pros) %><br />
    <%: Html.TextBox("Pros[]") %><br />
    <%: Html.TextBox("Pros[]") %><br />
    <%: Html.TextBox("Pros[]") %><br />
    <%: Html.TextBox("Pros[]") %><br />
    <%: Html.TextBox("Pros[]") %>
</p>
  • 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-17T23:06:15+00:00Added an answer on May 17, 2026 at 11:06 pm

    I believe you want something like:

    Html.CheckBoxFor(model => model.AdminGameReviewViewModel[i].IsSelected)
    

    within some loop that’s defined i in your View. Posting your View might help make this clearer.

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

Sidebar

Related Questions

Just what the title says, I need to change the password for an existing
Just as the title says, I see a lot of editors touting macro recording
I'm just about ready to cry. I have read the php.net manual page, tried
The title pretty much says it all. I'm trying to use jQuery's ability (hoping
I think the title pretty much says it all... I'm looking to implement an
Just as the title says. As i went through different explanations for choices made
Just what the title says: The subprocess module cannot be used as this should
Just as in title. Is suspect it is, but I couldn't find it anywhere
Title says what i'm trying to do. I can successfully generate an assembly if
Title says it mostly. I want to add a simple extension method to the

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.