loads of useful information, examples and tutorials pertaining to web development utilizing asp.net, c#, vb, css, xhtml, javascript, sql, xml, ajax and everything else...

 



Advertise Here
C-Sharpener.com - Programming is Easy!  Learn Asp.Net & C# in just days, Guaranteed!

No applicable method 'Contains' exists in type 'String'

by naspinski 11/18/2008 10:38:00 AM

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.

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

asp.net

Related posts

Comments

11/20/2008 10:12:08 AM

RJ
You killed Kenny!

RJ us


Comments are closed