?
Solved

C# DataGridViewRow

Posted on 2012-04-02
3
Medium Priority
?
479 Views
Last Modified: 2012-04-03
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%'
0
Comment
Question by:InfoTechEE
3 Comments
 
LVL 21

Expert Comment

by:masterpass
ID: 37798736
Why don't you just use the contains ?!!!

try like this

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

Open in new window

0
 

Author Comment

by:InfoTechEE
ID: 37798827
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
 
LVL 16

Accepted Solution

by:
Vikram Singh Saini earned 2000 total points
ID: 37798985
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question