C# DataGridViewRow

I am trying to see if a cell inside my DataGridViewRow contains a certain word -- "TFT".

if (row.Cells["Case Name"].Value.Equals("TFT")) // works great at checking if it equals the word I'm looking for, but I need to check for "contains" not "equals". How would I go about doing that?

The equivalent of what I'm looking for in SQL would be: WHERE CaseName like '%TFT%'
InfoTechEEAsked:
Who is Participating?
 
Vikram Singh SainiConnect With a Mentor Software Engineer cum AD DeveloperCommented:
Try

if (row.Cells["Case Name"].Value.ToString().Contains("TFT"))

Open in new window


instead of

if (row.Cells["Case Name"].Value.Equals("TFT"))
0
 
masterpassCommented:
Why don't you just use the contains ?!!!

try like this

if (row.Cells["Case Name"].Value.Contains("TFT"))

Open in new window

0
 
InfoTechEEAuthor Commented:
It says object does not contain a definition for Contains. Also, I don't see it as an option after:

if (row.Cells["Case Name"].Value.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.