Solution for this annoying error while using a LinqDataSource
Recently, I was making a seemingly harmless LinqDataSource and I came across this error. I was using the simple (I thought):
Where="title.Contains(@title)"
This error kept popping up and confusing me...
Contains sure does exist in
String, so why the error?
Turns out that it is trying to run
Contains on a NULL - and where does that NULL come from? A tricky little property in your
ControlParameter that defaults to true, and you have to manually change it to false:
ConvertEmptyStringToNull="false"
And that should cause your
Contains to work now, because every string
Contains a
String.Empty.