If your data source is DataTable then you can do it as Mohamed Mitwali has suggested.
Similarly if your data source is DataSet then you can do it like this:
DataSet ds = (DataSet)dataGridView.DataSource;
DataTeble dt = ds.Tables[dataGridView.DataMember];
DataRow[] resultSet = dt.Select("Your query goese here");
If your data source is List or (or IList<t> or any other collection which implements IEnumerable<t>) then you can extract it and do easy Linq query:
IEnumerable<someobject> rows = IEnumerable<someobject>dataGridView.DataSource;
var results = rows.Where(r => r.SomeProperty == SomeValue).ToList();</someobject></someobject>
You can also make a loop and go through all rows and check their values; I would use this approach only when I have unbounded columns in my dataGridView and I want to use those values for filtering.
foreach(var row in dataGridView.Rows)
{
if((row.Cells[columnIndex_Or_Name].Value as SomeType) == SomeValue)
{
}
}