how to remove empty rows by using linq query

how to remove empty rows by using linq query

use this Linq
nonEmptyRows = data.Where(row => !string.IsNullOrWhiteSpace(row)).ToList();
Use this query to store the data without empty rows
dt = dt.AsEnumerable().Where(Function(row) Not row.ItemArray.All(Function(field) String.IsNullOrWhiteSpace(field.ToString()))).CopyToDataTable()
or
dt= dt.AsEnumerable().Where(Function(row) Not String.IsNullOrWhiteSpace(row.Field(Of String)("ColumnName"))).CopyToDataTable()
hi
try this
datatable.asenumerable.where(function(x) not string.isnullorempty(x(“codes”).tostring)).copytodatatable
dt.AsEnumerable.Where(Function(r) not string.IsNullOrEmpty(r(0).ToString)).CopyToDataTable
refer this
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.