The schema or task is unclear, as you have not explained how would you find the records that are added to the database. I would assume that your
item
object holds a property "
IsSaved
".
That said, the checkbox input can be altered for its state like this,
@foreach (var item in ViewBag.Result)
{
<tr>
<td>
<input type="checkbox" checked="@item.IsSaved"
id="@item.RecordID" name="res" class="chkres" /></td>
<td>@item.UnitNo</td>
</tr>
}
This would now check for a value, either true or false. Then it would either check it, or leave it unchecked. That depends on your object. Implement it in a way that it represents your system.