.NET     Console.WriteLine( "All Things .NET" );
.NET Nerd Blog Home
3.13.2002

 

Filter Rows from DataTable into another DataTable




DataTable tNew = new DataTable("LowNumberedNodes");
DataRow[] rows = ds.Tables[0].Select( "T1NID < 5" );
for ( int i=0; i<rows.Length; i++ )
tNew.ImportRow( rows[i] );

Thanks to Kraldon for pointing out the c# way of doing this would be:

DataTable tNew = new DataTable("LowNumberedNodes");
foreach ( DataRow r in ds.Tables[0].Select( "T1NID < 5" ) )
tNew.ImportRow( r );


Comments: Post a Comment

Powered by Blogger