Datatable search

  • Thread starter Thread starter arun.hallan
  • Start date Start date
A

arun.hallan

I have a datatable with different id's in it. Each id has a set of
attribute pairs.

EG

id - attribute name - attribute value
========================
dog -legs - 4
dog - barks - true
cat - legs - 4
cat - barks - false


I simple want to query the table, like in sql, and select an attribute
by id.

eg: select attribute value where id=cat and attribute name =legs

to find out how many legs a cat has got.

Is there an easy way to do this with a datatable?
Thanks
 
Yes, there is. See the Select method on the DataTable class. The
documentation for the method will tell you the syntax you need to use to
filter on this.

You might also want to consider a DataView as well, depending on what
you are going to do with it.

Hope this helps.
 
Back
Top