How can I filter a DataColumn on a TimeSpan value?

天大地大妈咪最大 提交于 2019-12-11 14:12:55

问题


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

回答1:


I found it...

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


来源:https://stackoverflow.com/questions/3731596/how-can-i-filter-a-datacolumn-on-a-timespan-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!