Hello all
I found alot of LINQ syntax but all in VB not in C# how i can remove all rows who have empty or null values
without mention the column name ?
And with mention the column name?
Hello all
I found alot of LINQ syntax but all in VB not in C# how i can remove all rows who have empty or null values
without mention the column name ?
And with mention the column name?
Hi @Hazem_Saleh
Try using the following query:
var filteredRows = originalTable.Rows.Cast<DataRow>()
.Where(row => row.ItemArray.All(field => !string.IsNullOrWhiteSpace(field.ToString())))
.CopyToDataTable();
Hope this helps,
Best Regards.
Hi @Hazem_Saleh,
use below syntax to get not null rows for particular column
dt=dt.Select("ColumnName <>''").CopytoDataTable()
use below syntax to get not null rows for All column
DataTableName=DataTableName.Rows.Cast(Of DataRow)().Where(Function(row) Not row.ItemArray.All(Function(field) field Is DBNull.Value Or field.Equals(""))).CopyToDataTable()
Regards,
Arivu
… are keywords of VB.Net languague
When your topic title is still valid then you are looking for C# Statements:
So what is finally needed C# or Vb.Net?
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.