How to remove empty rows by using linq query

how to remove empty rows by using linq query

image

@chowdaryharitha55

use this Linq

nonEmptyRows = data.Where(row => !string.IsNullOrWhiteSpace(row)).ToList();

Hi @chowdaryharitha55

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()

@chowdaryharitha55

hi

try this

datatable.asenumerable.where(function(x) not string.isnullorempty(x(“codes”).tostring)).copytodatatable

@chowdaryharitha55

dt_2.AsEnumerable.where(function(x) not x("codes").equals("")).CopyToDataTable

1 Like

@chowdaryharitha55

dt.AsEnumerable.Where(Function(r) not string.IsNullOrEmpty(r(0).ToString)).CopyToDataTable

refer this

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.