如何在TimeSpan值上过滤DataColumn? [英] How can I filter a DataColumn on a TimeSpan value?

查看:97
本文介绍了如何在TimeSpan值上过滤DataColumn?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#.NET编程。我有一个名为Time的DataTable类型为System.TimeSpan。当我在DataGridView中显示DataTable时,我想过滤出没有列出时间的所有条目。我尝试过以下但没有效果。你可以帮忙吗?

  DataView myDataView = new DataView(SomeDataTable); 
myDataView.RowFilter + =Time> = 1; //不起作用
myDataView.RowFilter + =Time> =#00:00:01#; // does not work
myDataView.RowFilter + =Time<>; // does not work
myDataView.RowFilter + =Time<>; //不工作


解决方案

我发现了。

  myDataView.RowFilter =Convert(Time,System.String)&' 


Programming in C#.NET. I have a DataTable with a column named Time which is of type System.TimeSpan. When I display the DataTable in a DataGridView I want to filter out all the entries that don't have a time listed. I have tried the following but to no avail. Can you help?

DataView myDataView = new DataView(SomeDataTable);
myDataView.RowFilter += "Time >= 1";  // doesn't work
myDataView.RowFilter += "Time >= #00:00:01#";  // doesn't work
myDataView.RowFilter += "Time <> ''";  // doesn't work
myDataView.RowFilter += "Time <> ''";  // doesn't work

解决方案

I found it...

myDataView.RowFilter = "Convert(Time, System.String) <> ''";

这篇关于如何在TimeSpan值上过滤DataColumn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆