如何根据今天的日期查看数据?
我需要根据今天的日期查看数据
,这是控制器代码:
public ActionResult Edit(int programId, int hospitalNo ,DateTime CountDate )
{
var stat = _context.STATISTICS.Where(d => d.program_id == programId && d.hospital_no == hospitalNo && d.DATE == CountDate).ToList();
return View(stat);
}
这是打开视图的按钮:
我创建了会话参数保存登录日期并尝试调用它,但它不起作用:
Session["LoginDate"] = DateTime.Now.ToShortDateString();
@Html.ActionLink("Statistics", "Edit","Statistics", new {programId = item.program_id, hospitalNo = item.hospital_id ,CountDate = Convert.ToDateTime(Session["LoginDate"]) }, new { @class = "btn btn-info" })
如何查看数据基于今天的日期或从统计表中读取数据,有日期列,但是问题在另一个视图中,我无法分配值
项。
以前我该如何做并查看数据取决于今天的日期?
I need to view the data based on today date only
This is the controller code :
public ActionResult Edit(int programId, int hospitalNo ,DateTime CountDate )
{
var stat = _context.STATISTICS.Where(d => d.program_id == programId && d.hospital_no == hospitalNo && d.DATE == CountDate).ToList();
return View(stat);
}
and this is the button which open the view :
I created session parameter saving login date and tried to call it but its not working :
Session["LoginDate"] = DateTime.Now.ToShortDateString();
@Html.ActionLink("Statistics", "Edit","Statistics", new {programId = item.program_id, hospitalNo = item.hospital_id ,CountDate = Convert.ToDateTime(Session["LoginDate"]) }, new { @class = "btn btn-info" })
How can I view the data based on the today date or read the data from STATISTICS table there is DATE column but the issue the button in another view and I cannot assign the value
item.DATE
How can I do it and view the data depends on today date ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在操作链接中传递的数据将通过查询参数传递到控制器,并且系统只能在此处读取字符串和整数。您试图尝试在查询参数中传递C#对象,这就是为什么它可能对您不起作用的原因。我建议您更改下面的按钮代码:
以及您的控制器代码如下:
the data that you pass in Action Link , will pass on to the controller via query params and the system could read only string and integers there. What you are trying to attempt is to pass a C# object in query params, which was why it might not be working for you. I would suggest you to change your button code like to below:
and your controller code like below: