问题
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