c# - 刷新页面以显示当前时间的统计信息
问题描述
Ι 有一个页面可以从特定日期和时间带回gridview(硬编码)
我怎样才能改变这一点,以便数据显示今天的统计数据?我还希望它在特定时间开始,然后在给定时间后重置,例如 6am-2pm - 2pm-10pm - 10pm - 6am。
public void Refreshdata(int selectedProduct)
{
BizManager biz = new BizManager();
GridView1.DataSource = biz.GetPacktstatisticsForShift(new DateTime(2016, 6, 10, 6, 0, 0)
, new DateTime(2016, 6, 10, 13, 59, 59)
, selectedProduct).DefaultView;
GridView1.DataBind();
public void Dropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
{
int productId;
if(int.TryParse(DropDownList1.SelectedValue, out productId))
Refreshdata(productId);
解决方案
只需向方法添加更多参数并传递它们:
public void Refreshdata(int selectedProduct, DateTime shiftStart, DateTime shiftEnd)
{
BizManager biz = new BizManager();
GridView1.DataSource = biz.GetPacktstatisticsForShift(
shiftStart
, shiftEnd
, selectedProduct).DefaultView;
GridView1.DataBind();
}
public void Dropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
{
DateTime shiftStart = DateTime.Today;
DateTime shiftEnd = DateTime.Today.AddDays(1).AddMinutes(-1);
int productId;
if(int.TryParse(DropDownList1.SelectedValue, out productId))
Refreshdata(productId, shiftStart, shiftEnd);
}
推荐阅读
- r - 在 R 中的绘图上显示日期的问题
- esp32 - Serial.printf() 带有长度为 11 或更大的 String 对象
- accessibility - 如何使用键盘快捷键导航到网页上的最后一个可操作元素(适用于 MAC)
- sql-server - 如何在 SQL Server 18 中将 INT 转换或转换为日期
- javascript - 在 Switch Case 中添加类后移除类
- docusignapi - 有没有办法通过 API 导入 JSON 模板导出?
- python - 如何检查列表和 DF 的记录之间是否匹配,并根据匹配的存在返回匹配的值
- node.js - 有没有办法在 mongodb 中获取事务号或 id?
- jenkins - Jenkins-Terraform 无法销毁任何实例
- moodle - de acesso na plataforma Moodle 版本 3.10.1