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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:13:10+00:00 2026-05-31T22:13:10+00:00

I have these view models. public class MasterFrmVm { public Guid Id { get;

  • 0

I have these view models.

public class MasterFrmVm
{
    public Guid Id { get; set; }
    public IList<FrmVm> FrmVms { get; set; }

    public MasterFrmVm()
    {
         RewardTierFrmVm = new List<RewardTierFrmVm>();
    }
}

public class FrmVm
{
    public Guid Id { get; set; }
    public IList<GroupedStoreVm> GroupedStoresVm { get; set; }

    public FrmVm()
    {
         GroupedStoresVm = new List<GroupedStoreVm>();
    }
 }

 public class GroupedStoreVm
 {
     public string CountryName { get; set; }
     public string CountryId { get; set; }
     public IList<StoreGroupingVm> StoreGroupingVms { get; set; }

     public GroupedStoreVm()
     {
          StoreGroupingVms = new List<StoreGroupingVm>();
     }
 }

 public class StoreGroupingVm
 {
      public string Name { get; set; }
      public Guid Id { get; set; }
      public IList<StoreVm> StoreVms { get; set; }
 }

 public class StoreVm
 {
      public Guid Id { get; set; }
      public string Name { get; set; }
 }


 @foreach (var f in Model.FrmVm )
 {
      @Html.Partial("GenerateTier", f)
 }


//GenerateTier
     @model FrmVm
     <ul class="storeTree">  
     @for (int i = 0; i < Model.GroupedStoresVm.Count; i++)
     {
                     <li>
                        <input type="checkbox" name="@Model.GroupedStoresVm[i]" value="@Model.GroupedStoresVm[i].CountryId" />@Model.GroupedStoresVm[i].CountryName
                        <ul>
                              @for (int x = 0; x < Model.GroupedStoresVm[i].StoreGroupingVms.Count; x++)
                            {
                                <li>
                                   @Html.CheckBox(Model.GroupedStoresVm[i].StoreGroupingVms[x].Name , false, new { value = Model.GroupedStoresVm[i].StoreGroupingVms[x].Id }) @Model.GroupedStoresVm[i].StoreGroupingVms[x].Name                                
                                    <ul>
                                       @for (int z = 0; z < @Model.GroupedStoresVm[i].StoreGroupingVms[x].StoreVms.Count; z++)
                                       {
                                           <li>@Html.CheckBox(Model.GroupedStoresVm[i].StoreGroupingVms[x].StoreVms[z].Name, false)@Model.GroupedStoresVm[i].StoreGroupingVms[x].StoreVms[z].Name  </li>
                                       }
                                    </ul>
                                 </li>                                      
                            }                    
                        </ul>                 
                     </li>        
                }
                </ul>

I am basically making a checkbox tree (then using a jquery plugin I make it look like a tree). However I am not sure how to make the checkboxes so they bind. Normally I would use strongly typed html helper but I just don’t know how it would look as it wants a bool value.

So I tried both the non strongly typed helper and just html but I can’t figure out how to make it so when I have my controller it binds.

public ActionResult (FrmVm vm)
{
}

I am using jquery and serializing it and sending it via Ajax.

Edit

I also forgot to mention the FrmVm is another view Model as it too can also be many.

@foreach (var f in Model.FrmVm)
{
     @Html.Partial("GenerateTier", f)
}

what then has the code I showed above. Now added to my code.

Edit 2

Here is what I see in firebug

FrmVm%5Bd06a6c21-1796-4fb5-9af5-cbf973c6c820%5D.a=a
&FrmVm%5Bd06a6c21-1796-4fb5-9af5-cbf973c6c820%5D.a=false

&FrmVm%5Bd06a6c21-1796-4fb5-9af5-cbf973c6c820%5D.3=70563225-2718-40ec-8a71-a01500a66183
&FrmVm%5Bd06a6c21-1796-4fb5-9af5-cbf973c6c820%5D.3=false

&FrmVm%5Bd06a6c21-1796-4fb5-9af5-cbf973c6c820%5D.1=dbd43e7e-86e4-4fa1-9e48-a01a00db151c
&FrmVm%5Bd06a6c21-1796-4fb5-9af5-cbf973c6c820%5D.1=false

The structure would be (they would be checkboxes of course)

-a
  - 3
     -1

not sure why it says they are all false as I checked them all.

  • 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-31T22:13:11+00:00Added an answer on May 31, 2026 at 10:13 pm

    When your viewmodel has a property defined as a bool then the helper @Html.EditorFor(model => model.boolProperty) will automatically produce a checkbox.

    In response to your comment, perhaps something like this?

    public class myViewModel
    {
     List<boolNames> firstList { get; set; }
     List<boolNames> anotherList { get; set; }
    }
    
    public class boolNames
    {
     public string Name { get; set; }
     public int GUID { get; set; }
     public bool checkBox { get; set; }
    }
    

    view

    @for(int i = 0 ; i < Model.firstList.Count ; i++ )
    {
     <div id="@(Model.firstList[i].GUID)">
     <span>@Model.firstList[i].Name</span>
     <span>@Html.EditorFor(model => model.firstList[i].checkBox)</span>
     </div>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following view models: public class Search { public int Id {
Say I have the following models: public class Item { public int Id{ get;
I have these 2 methods in the View class. the drawRect method always gets
I have a view model that looks like this: public class VenueIndexViewModel : BaseViewModel
I have a View Model that is defined as follows: public class VariableViewModel {
I have a view model which is just public class Visits { public List<Visit>
Given the following Model, public class A { public string Name { get; set;
Ok, I have 2 models that inherit from one abstract class: public abstract class
I have the following model: public class Person { public string Name { get;
I have these two models: class Application_Model_List extends Zend_Db_Table_Abstract { protected $_name = 'list';

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.