如何在dataview中过滤数据. [英] how to filter data in dataview.
本文介绍了如何在dataview中过滤数据.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可能收到此错误无法在System.String和System.Double上执行''< =''操作
I ma getting this error Cannot perform ''<='' operation on System.String and System.Double
string date = System.DateTime.Today.ToString("dd/MM/yyyy");
DataTable dtCopyTemplates = drTemplates.CopyToDataTable();
string matching = "LastDate <=" + date ;
DataView dv = new DataView(dtCopyTemplates, matching, "", DataViewRowState.CurrentRows);
请帮助我.
plz help me.
推荐答案
您不应该将字符串与日期和时间进行匹配,
如果您想这样做,那么您需要考虑两件事
1)应该为yyyyMMdd格式
2)应该是double类型而不是string类型.
希望你明白我的意思,
谢谢
-Amit.
Hi,
you should not do string matching with Date and time,
if you would like to do that then you need consider 2 things
1) it should be in yyyyMMdd format
2) it should be of type double not string.
hope you got my point,
thanks
-Amit.
尝试使用Linq: http://msdn. microsoft.com/en-us/library/bb669073.aspx [ ^ ]
请参阅倒数第二个示例.
try using Linq: http://msdn.microsoft.com/en-us/library/bb669073.aspx[^]
refer to the second to the last example.
查看此代码项目Q/A ^ ]
--NDK
look this code project Q/A how to filter data from data table to compair with date.[^]
--NDK
这篇关于如何在dataview中过滤数据.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文