title: Saving all checkbox values from WebGrid in MVC 4
body: <p>I am new to MVC 4. I am stuck in a situation and want some suggestions to resolve the problem. The problem scenario is:</p>
  
  <p>I am rendering a WebGrid inside a partial view and the WebGrid format is as follows:
  <img src="https://i.stack.imgur.com/QMNsC.jpg" alt="enter image description here"></p>
  
  <p>An IEnumerable collection is bound with the WebGrid. The view for binding WebGrid is:</p>
  
  <pre><code>@{    
  MIS.Areas.AdminModule.Models.AdminModuleViewModels.Module_UserGrp_Permission allPermissions = new MIS.Areas.AdminModule.Models.AdminModuleViewModels.Module_UserGrp_Permission();    
  </code></pre>
  
  <p>}</p>
  
  <pre><code>    @{
  var grid = new WebGrid(Model, canPage: true, rowsPerPage: 10, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "Title");
  grid.Pager(WebGridPagerModes.NextPrevious);}
      &lt;div id="gridContent"&gt;
          @grid.GetHtml(tableStyle: "webGrid",
              headerStyle: "header",
              alternatingRowStyle: "alt",
              selectedRowStyle: "select",
              columns: grid.Columns(
              grid.Column(header: "Select",
              format: @&lt;input class="select" id="assignChkBx" name="assignChkBx" type="checkbox" @allPermissions.intMenuId/&gt;),
              grid.Column(header: "MenuId", format: (item) =&gt; item.intMenuId, style: "description"),
              grid.Column(header: "Menu", format: (item) =&gt; item.strMenuName, style: "description", canSort: true),
              grid.Column(header: "Add", format: @&lt;text&gt;&lt;input name="Add" type="checkbox"  @(item.boolAddPer == true ? "Checked" : null) id="chkboxIsActiveAdd" /&gt;&lt;/text&gt;),
              grid.Column(header: "Edit", format: @&lt;text&gt;&lt;input name="Edit" type="checkbox"  @(item.boolEditPer == true ? "Checked" : null) id="chkboxIsActiveEdit" /&gt;&lt;/text&gt;),
              grid.Column(header: "Delete", format: @&lt;text&gt;&lt;input name="Delete" type="checkbox"  @(item.boolDeletePer == true ? "Checked" : null) id="chkboxIsActiveDelete" /&gt;&lt;/text&gt;),
              grid.Column(header: "Grant", format: @&lt;text&gt;&lt;input name="Grant" type="checkbox"  @(item.boolGrantPer == true ? "Checked" : null) id="chkboxIsActiveGrant" /&gt;&lt;/text&gt;)
  
       ))                       
      &lt;/div&gt;
  </code></pre>
  
  <p>And fetching data from database as follows (I am NOT using EntityFramework) :</p>
  
  <p>var result = from column in dt.AsEnumerable()</p>
  
  <pre><code>                     select new Module_UserGrp_Permission
                       {
                           intMenuId = Convert.ToInt32(column["MenuId"]),
                           intUserGrpId = Convert.ToInt32(column["UserGrpId"]),
                           strMenuName = Convert.ToString(column["MenuName"]),
  
                           boolAddPer = Convert.ToBoolean(column["boolGAdd"]),
                           boolEditPer = Convert.ToBoolean(column["boolGEdit"]),
                           boolDeletePer = Convert.ToBoolean(column["boolGDel"]),
                           boolViewPer = Convert.ToBoolean(column["boolGView"]),
                           boolGrantPer = Convert.ToBoolean(column["boolGGrant"])
                       };
          return new List&lt;MIS.Areas.AdminModule.Models.AdminModuleViewModels.Module_UserGrp_Permission&gt;(result);
  </code></pre>
  
  <p>Now the problem is I have to save all the checked/unchecked items from this WebGrid.
  What should I do to save all the values after clicking the 'Save' button. 
  Please suggest possible solutions.</p>
  
  <p>Thank you all.</p>