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

  • Home
  • SEARCH
  • 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 6955735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:46:34+00:00 2026-05-27T14:46:34+00:00

I have this scenario. I have 10 checkboxes that need to be generated(this list

  • 0

I have this scenario. I have 10 checkboxes that need to be generated(this list could grow and comes from the database).

Now a user may only have 3 of the 10. I want to always show all 10 checkboxes to the user but only check the ones they have.

I am unsure how my viewmodel and page should look like? I am unsure which html helper to be using. If I need a property(bool) for each of the values in the database showing which value they have.

It my database I don’t have a bit value showing if they have it or not. I have a many to many relationship. A user can have many features and a feature can have many users.

  • 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-27T14:46:35+00:00Added an answer on May 27, 2026 at 2:46 pm

    Build view models to describe your User and Feature objects. Then, you could use an editor template to display the checkbox.

    public class UserFeatureViewModel
    {
        public string Name { get; set; }
        public IEnumerable<FeatureViewModel> Features { get; set; }
    }
    
    // and the FeatureViewModel
    public class FeatureViewModel
    {
        public string Name { get; set; }
        public bool IsSelected { get; set; }
    }
    

    I said build, so do that in your controller, view model factory or service. The Feature instances are hard-coded here, but you’d want to retrieve them from the db:

    public class UserController : Controller
    {
        public ActionResult GetUser(string username)
        {
            var model = new UserFeatureViewModel
            {
                Name = username,
                Features = new[]
                {
                    new FeatureViewModel { Name = "Feature abc", IsSelected = true },
                    new FeatureViewModel { Name = "Feature def", IsSelected = false },
                    new FeatureViewModel { Name = "Feature xyz", IsSelected = true }
                }
            };
            return View(model);
        }
    }
    

    You can use subsequent actions with UserFeatureViewModel parameters for updating, etc.

    Finally, the editor template in ~/Views/User/EditorTemplates/FeatureViewModel.cshtml would inherit a FeatureViewModel and use the Html.CheckBoxFor helper:

    @model FeatureViewModel
    <span>@Model.Name</span>
    <span>@Html.CheckBoxFor(model => model.IsSelected)</span>
    

    In your form (the “parent” view), use the EditorFor helper to render the partial

    @Html.EditorFor(model => model.Features)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this scenario. I have my own website, that I use as my identifier,
So...I have this scenario where I have a Foreach loop that loops through a
I have this scenario. I want group on Country and Category. A store can
I have this scenario where I would like to redirect my domains using the
Imagine this scenario: You have a desktop and a laptop. The desktop has a
Consider this scenario. I have an object, lets call it.... Foo. Foo raises a
In this scenario, I have 2 or more models: class Store(models.Model): name = models.CharField(max_length
Please Consider this scenario: We have a base class called clsMain : class clsMain
The architecture for this scenario is as follows: I have a table of items
Maybe it's not worth worrying about in this scenario, but lets say you have

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.