如何解决检查GridView中的日期是否与当前日期匹配
protected void LinkButton_Click(Object sender,EventArgs e)
{
String MyConnection2 = "Server=localhost;database=ovs;Uid=root;password=; Convert Zero Datetime=True";
DateTime time = DateTime.Today; // Use current time
GridViewRow Grdrow = (GridViewRow)((LinkButton)sender).NamingContainer;
Label lbleddate = (Label)Grdrow.Cells[0].FindControl("lbleddatae");
Label lblstdate= (Label)Grdrow.Cells[0].FindControl("lblstdate");
string sdate = lblstdate.Text;
string edate = lbleddate.Text;
DateTime stdate= Convert.ToDateTime(sdate);
DateTime eddate = Convert.ToDateTime(edate);
DateTime today = DateTime.Today;
if (!(time.Equals(edate)))
{
Label2.Text = "Please chenk the eletion date!";
}
else {
// execute query
}
}
start date and end date store in database 我希望获取的开始日期和结束日期显示为gridview(标签),并与当前日期进行比较。如果不等于开始日期和结束日期,则显示错误消息“请检查选举日期!”。我遇到的错误是当前日期为21/10/2020,并且gridview中显示的日期开始日期和结束日期也为21/10/2020,但将显示错误消息,并且无法执行查询。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。