ASP.NET MVC 5 Razor view map checkbox to a date field
user7569 Published in September 20, 2018, 12:43 pm
I am relatively new to ASP.NET MVC. I have an MVC 5 application that's displaying results to a DataTable using the DataTable.net library. The field I'm trying to modify is a Date field but it's converted to a string by the View. What I'd like to do is add a checkbox to the left of the date string and if the date has a value in it then make the box checked. If it doesn't have a value then leave it unchecked. This is without adding a boolean field to the table. Just strictly reading if the field is null and toggling the checkbox based off of checking if it's null. Then the user can select multiple records and pass the selected records to the controller and update the database. I've tried doing a Checkboxfor but it complains about not being able to convert a system.date to a boolean.
Below is the section of code for the view that populates the Table: