i want to filter or search between 2 date i write this code , but when i run the application the data which in the table not show what is the wrong ?
This is my controller :
public ActionResult Index(DateTime? start, DateTime? end)
{
var ExpenseDetails = _context.ExpenseDetails.Include(s => s.expenses).Where(t => t.DateExpense >= start && t.DateExpense <= end).ToList();
return View(ExpenseDetails);
}
and this is View :
@using (Html.BeginForm())
{
<div>
<span>Start Date :</span> <input type="date" name="start" />
<span>End Date :</span> <input type="date" name="end" />
<input type="submit" value="Get Records Between Dates" />
</div>
<table>
@foreach (var item in Model)
{
<tbody>
<tr>
<td>
@Html.DisplayFor(modelItem => item.expenses.Expenses_Type)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateExpense)
</td>
<td>
@Html.DisplayFor(modelItem => item.Amount)
</td>
</tbody>
}
</table>
}
Thank you