检查从日期和Gridview行选择日期我尝试但它不工作 [英] Checking Selected From Date And Gridview Row Date I Tried But It Is Not Working
本文介绍了检查从日期和Gridview行选择日期我尝试但它不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码如下
My code as follows
DateTime selectedfromdate = Convert.ToDateTime(Txtfromdate.SelectedDateValue);
for (int i = 0; i < GvSch.Rows.Count; i++)
{
GridViewRow rows = GvSch.Rows[i];
if (selectedfromdate == rows.Cells[0].Text.ToString().Trim())
{
Lblerr.Text = "selected date and excel sheet should be same";
return;
}
}
当我运行时显示错误如下
When i run shows error as follows
Operator == cannot be applied to operands of type 'System.date.time' and 'String'
从上面的代码中可以看出什么是错误的我发了吗?
请帮帮我。
问候,
Narasiman P
From my above code what is the misktake i made?
please help me.
Regards,
Narasiman P
推荐答案
尝试下面的代码
Try the below code
if (selectedfromdate.ToShortDateString().equals(rows.Cells[0].Text.ToString().Trim()))
{
Lblerr.Text = "selected date and excel sheet should be same";
return;
}
这篇关于检查从日期和Gridview行选择日期我尝试但它不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文