Hi mahesh213,
This error is because DateTime? means it's nullable DateTime.
So before assigning it to DateTime you need to check if it contains value and only then assign.
Check if datetime contains value and if not return any other value which you want.
Use the below code.
[HttpPost]
public JsonResult getAll1(DateTime? Id5)
{
DateTime dt = Id5.HasValue ? Id5.Value : DateTime.Now;
var result = db.PayProcess(dt).ToList();
var JsonResult = Json(result, JsonRequestBehavior.AllowGet);
JsonResult.MaxJsonLength = int.MaxValue;
return JsonResult;
}
Or change signature of method to remove nullable.
[HttpPost]
public JsonResult getAll1(DateTime Id5)
{
var result = db.PayProcess(Id5).ToList();
var JsonResult = Json(result, JsonRequestBehavior.AllowGet);
JsonResult.MaxJsonLength = int.MaxValue;
return JsonResult;
}