Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if String / Record exists in DataTable

Tags:

c#

datatable

I have a String and I need to check if any column "item_manuf_id" in DataTable dtPs.Rows equals to certain value

I can loop over all Rows and compare

String id = dtPs.Rows[number]["item_manuf_id"].ToString()
if ("some value".equals(id)) etc.

but I am wondering if there is any way to check if DataTable contains the record

like image 915
Andrew Avatar asked Aug 14 '12 21:08

Andrew


1 Answers

Something like this

 string find = "item_manuf_id = 'some value'";
 DataRow[] foundRows = table.Select(find);
like image 112
Orn Kristjansson Avatar answered Sep 21 '22 15:09

Orn Kristjansson