• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 483
  • Last Modified:

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%'
1 Solution
Why don't you just use the contains ?!!!

try like this

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

Open in new window

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.
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:

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

Open in new window

instead of

if (row.Cells["Case Name"].Value.Equals("TFT"))
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.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now