Click here to Skip to main content
16,022,418 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,

How to verify whether a particular row exist or not in a datatable.

how to do it.

Thanks in Advance.
Subhash G
Posted

use datatable select method which has parameter filterexpression as string
this will get the filtered rows in datarow check if datarow is null

C#
DataRow[] dr = dt.Select("where id=" + id);
 
Share this answer
 
Alternatively use dataview

<pre lang="vb">
'assumming datatable is named dt
Dim dv As new DataView(dt)
dv.RowFilter = "id = " & ID
If dv.Count >0 Then
'Row exists
End if
</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900