Datatable search

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

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

Top