I want to check TempDatainside the conditions if. But I get an error message.
My controller
public ActionResult Customer(PurchaseViewModel purchaseviewmodel)
{
TempData["Fromdt"] = purchaseviewmodel.FromDate;
TempData["todt"] = purchaseviewmodel.ToDate;
If(TempData["Fromdt"] == Convert.ToDateTime("01/01/0001")&& TempData["todt"] == Convert.ToDateTime("01/01/0001"))
{
}
else
{
}
return View(Customer);
}
Why am I getting model values in Tempdata, I want to pass the values that I get in TempDate for another action. Therefore, I use only TempData. Now I get the error. Error
The == operator is not applied between the object and System.DateTime.
I tried my level to explain the problem. Therefore, it helps me to solve this problem. And I need TempData not to store the values directly in the variable. I can save the value in a variable like
var fmdt = purchaseviewmodel.FromDate;
var todt = purchaseviewmodel. ToDate;
TempData , TempData .