0

I have a datatable which is having n no. of rows and each row has a unique field say ID.
Now I want to get a particular row for a specified ID.
eg. there are 5 rows in a datatable and the id's are
1,2,3,4 and 5 and if I want to select a row having ID = 4
What will be the code snippet for that?
Does anybody have any idea?
Thanks in advance,

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by corwing
0

I have a datatable which is having n no. of rows and each row has a unique field say ID.
Now I want to get a particular row for a specified ID.
eg. there are 5 rows in a datatable and the id's are
1,2,3,4 and 5 and if I want to select a row having ID = 4
What will be the code snippet for that?
Does anybody have any idea?
Thanks in advance,

Other than the obvious datatable.Rows[3]

you can do a Select within the table
DataRow[] rws = datatable.Select("ID=4");

0

The first thing we need to know to help you is..
How are you handling the datatable?
Is it a two-dimensional array, a class a collection of rows or columns?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.