Reputation: 1988
Reading the contents from an xml to a datatable which is having a date column, and then filtering the datatable with DefaultView.RowFilter
with certain conditions. It works perfectly with conditions except the ones with date having null values in the column
Eg.
dt.DefaultView.RowFilter =" StartOn <=#" + Convert.ToDateTime(dtpToStart.Text) + "#"
if StartOn (date field)
contains any null value it shows following error message
Cannot perform
'>='
operation onSystem.String
andSystem.DateTime
.
I tried using "isnull(StartOn ,'11/11/2012')<=#"+ Convert.ToDateTime(dtpToStart.Text) +"#"
but it didn't work.
Upvotes: 0
Views: 2022
Reputation: 3046
Check for NULL before the range comparison.
For example:
dt.DefaultView.RowFilter ="StartOn IS NOT NULL AND StartOn <=#" + Convert.ToDateTime(dtpToStart.Text) + "#"
Upvotes: 2