Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to Convert webgrid data with checkbox to json in mvc?
here is my webgrid
HTML
 <div class="portlet-body">
<div class="task-content">
 <div id="gridContent">
<div class="table-responsive">
@grid.GetHtml(tableStyle: "webGrid",
headerStyle: "header",
 htmlAttributes: new { id = "subAssign" },
alternatingRowStyle: "alt",
mode: WebGridPagerModes.All,
firstText: "&lt;&lt; First",
previousText: "&lt; Prev",
nextText: "Next &gt;",
lastText: "Last &gt;&gt;",
columns: grid.Columns(
grid.Column(header: "Sr.No",
format: item => item.WebGrid.Rows.IndexOf(item) + 1 + Math.Round(Convert.ToDouble(grid.TotalRowCount / grid.PageCount) / grid.RowsPerPage) * grid.RowsPerPage * grid.PageIndex),
grid.Column("SubjectCode", "Subject Code"),
grid.Column("SubjectName", " Subject Name"),
grid.Column(columnName: "IsTheory", header: "Theory", canSort: false,
format: (item) =&gt; @Html.Raw("&lt;input type='checkbox'  ((Convert.ToInt32(item.IsTheory) == 1) ? "checked" : "") /&gt;")),
grid.Column(columnName: "IsPractical", header: "Practical", canSort: false,
format: (item) =&gt; @Html.Raw("&lt;input type='checkbox'  ((Convert.ToInt32(item.IsPractical) == 1) ? "checked" : "") /&gt;"))
 ))
 </div>
   </div>
 </div>
</div>


What I have tried:

All the data of webgrid is converting to json format except checkbox value is constant "True" even for unchecked box.
Posted
Updated 8-Aug-16 21:35pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900