我想在2个日期之间进行过滤或搜索,但我写了这段代码,但是当我运行应用程序时,表中未显示错误的数据是什么?
这是我的控制器:
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);
}
这是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>
}
谢谢
答案 0 :(得分:1)
在处理日期时,需要确认以下内容: