which column in a datarow?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I finally got a search in a datatable working (so that I can type "p", and
the first row with data beginning with a p is highlighted). I use this:
string searchThis = "p";
DataRow[] dr = tCat.Select("Customer LIKE'" + searchThis + "*'");
My problem is that I need to specify which column to search in. The way it
is now, if something starts with a p in the first column, it will highlight
the row. (I need to search one of four columns.) Is there any way to
determine which column the matched string was found in?
Thanks again so much!
Mel
 
The Select function does a search on a column. It's very similar to the
'WHERE' clause in your select statement.
Cheers,
Mark
 
So should this be enough to say to search in the column called Customer?

DataRow[] dr = tCat.Select("Customer LIKE'" + searchThis + "*'","Customer
ASC");

Thanks again,
Mel


Mark said:
The Select function does a search on a column. It's very similar to the
'WHERE' clause in your select statement.
Cheers,
Mark

melanieab said:
Hi,
I finally got a search in a datatable working (so that I can type "p", and
the first row with data beginning with a p is highlighted). I use this:
string searchThis = "p";
DataRow[] dr = tCat.Select("Customer LIKE'" + searchThis + "*'");
My problem is that I need to specify which column to search in. The way it
is now, if something starts with a p in the first column, it will highlight
the row. (I need to search one of four columns.) Is there any way to
determine which column the matched string was found in?
Thanks again so much!
Mel
 
Yes, take a look at MSDN for DataTable.Select.

Cheers,
Mark

melanieab said:
So should this be enough to say to search in the column called Customer?

DataRow[] dr = tCat.Select("Customer LIKE'" + searchThis + "*'","Customer
ASC");

Thanks again,
Mel


Mark said:
The Select function does a search on a column. It's very similar to the
'WHERE' clause in your select statement.
Cheers,
Mark

melanieab said:
Hi,
I finally got a search in a datatable working (so that I can type "p", and
the first row with data beginning with a p is highlighted). I use this:
string searchThis = "p";
DataRow[] dr = tCat.Select("Customer LIKE'" + searchThis + "*'");
My problem is that I need to specify which column to search in. The way it
is now, if something starts with a p in the first column, it will highlight
the row. (I need to search one of four columns.) Is there any way to
determine which column the matched string was found in?
Thanks again so much!
Mel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top