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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:10:02+00:00 2026-06-13T11:10:02+00:00

MVCContrib Grid: @model ViewModel @using (Html.BeginForm(SendData, Home, FormMethod.Post)) { @Html.Grid(Model.List).Columns(c => { c.For(x =>

  • 0

MVCContrib Grid:

@model ViewModel
@using (Html.BeginForm("SendData", "Home", FormMethod.Post))
{
    @Html.Grid(Model.List).Columns(c =>
    {
        c.For(x => x.Id);
        c.For(x => x.Name);
        c.For(x =>Html.Partial("Partial/CheckBoxTemplate", new CheckBoxViewModel { Id = x.Id })).Named("Options");
    })

    @Html.SubmitButton()
}

Controller Post Action:

public ActionResult SendData(List<CheckBoxViewModel> list)
{
    return View();
}

ViewModels:

public class CheckBoxViewModel
{
    public int Id { get; set; }
    public bool CheckBox { get; set; }
}

public class ViewModel
{
    public IPagination<Data> List { get; set; }
}

public class Data
{
    public int Id { get; set; }
    public string Name { get; set; } 
}

Partial View:

@model MvcApplication1.Models.CheckBoxViewModel

@Html.HiddenFor(x => x.Id)
@Html.CheckBoxFor(x => x.CheckBox)

All checkboxed are by default not checked.

How can I retrieve all checked checkbox values in my SendData action?

  • 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-06-13T11:10:03+00:00Added an answer on June 13, 2026 at 11:10 am

    I would recommend you to use a real view model that will reflect the requirements of your view (displaying a grid containing for each row a checkbox, and displaying the id and name of the item and retrieving those values in a list in your postback action):

    public class CheckBoxViewModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public bool CheckBox { get; set; }
    }
    
    public class ViewModel
    {
        public IPagination<CheckBoxViewModel> List { get; set; }
    }
    

    and then have your view strongly typed to this view model:

    @model ViewModel
    
    @using (Html.BeginForm("SendData", "Home", FormMethod.Post))
    {
        @Html.Grid(Model.List).Columns(c =>
        {
            c.For(x => x.Id);
            c.For(x => x.Name);
            c.For(x => Html.Partial("Partial/CheckBoxTemplate", x)).Named("Options");
        })
    
        <button type="submit">OK</button>
    }
    

    finally your partial could look like this:

    @model CheckBoxViewModel
    
    @{
        var index = Guid.NewGuid().ToString();
    }
    
    @Html.Hidden("list.Index", index)
    @Html.Hidden("list[" + index + "].Id", Model.Id)
    @Html.Hidden("list[" + index + "].Name", Model.Name)
    @Html.CheckBox("list[" + index + "].CheckBox", Model.CheckBox)
    

    Now when the SendData action is invoked it will be passed the list of your view model.

    Alternatively you could use the Html.BeginCollectionItem helper presented in the following article which would allow you to use the strongly typed versions of the helpers:

    @model CheckBoxViewModel
    @using(Html.BeginCollectionItem("list")) 
    {
        @Html.HiddenFor(x => x.Id)
        @Html.HiddenFor(x => x.Name)
        @Html.CheckBoxFor(x => x.CheckBox)
    }
    

    Recommended further reading: Model Binding To A List.

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

Sidebar

Related Questions

I am using a ASP.NET MVC 3 Mvccontrib grid like so: @Html.Grid(Model).Columns(column => {
I have the following partial view code @model IEnumerable<PDoc.Web.Models.UserDocModel> @using MvcContrib.UI.Grid; @using MvcContrib.UI.Pager; @using
I have the following code in a partial view; <%= Html.Grid(Model).Columns(column => { column.For(model
I'm not using a Grid, just using the MvcContrib Pager. I have a partial
@model SocialReader.BackOffice.Models.NewsAndCategories @using MvcContrib.UI.Grid; @using MvcContrib.UI.Pager; @using MvcContrib.Pagination; @using System.Linq; @using SocialReader.BackOffice.Common; @{ ViewBag.Title
I just started using the MVCContrib grid in a test project. I'm having a
I'd like for my column header to also be footers using MVCContrib grid. How
I currently have a product view page that contains an MVCContrib HTML Grid with
I am using the MVCContrib grid and I would like to display images depending
I've come across something odd with the MVCContrib Grid. Using Chrome (or FireFox), when

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.